annotate gcc/ada/output.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
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 U T P U T --
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) 1992-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. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package contains low level output routines used by the compiler for
kono
parents:
diff changeset
33 -- writing error messages and informational output. It is also used by the
kono
parents:
diff changeset
34 -- debug source file output routines (see Sprint.Print_Debug_Line).
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 with Hostparm;
kono
parents:
diff changeset
37 with Types; use Types;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 pragma Warnings (Off);
kono
parents:
diff changeset
40 -- This package is used also by gnatcoll
kono
parents:
diff changeset
41 with System.OS_Lib; use System.OS_Lib;
kono
parents:
diff changeset
42 pragma Warnings (On);
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 package Output is
kono
parents:
diff changeset
45 pragma Elaborate_Body;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 type Output_Proc is access procedure (S : String);
kono
parents:
diff changeset
48 -- This type is used for the Set_Special_Output procedure. If Output_Proc
kono
parents:
diff changeset
49 -- is called, then instead of lines being written to standard error or
kono
parents:
diff changeset
50 -- standard output, a call is made to the given procedure for each line,
kono
parents:
diff changeset
51 -- passing the line with an end of line character (which is a single
kono
parents:
diff changeset
52 -- ASCII.LF character, even in systems which normally use CR/LF or some
kono
parents:
diff changeset
53 -- other sequence for line end).
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -----------------
kono
parents:
diff changeset
56 -- Subprograms --
kono
parents:
diff changeset
57 -----------------
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 procedure Set_Special_Output (P : Output_Proc);
kono
parents:
diff changeset
60 -- Sets subsequent output to call procedure P. If P is null, then the call
kono
parents:
diff changeset
61 -- cancels the effect of a previous call, reverting the output to standard
kono
parents:
diff changeset
62 -- error or standard output depending on the mode at the time of previous
kono
parents:
diff changeset
63 -- call. Any exception generated by calls to P is simply propagated to
kono
parents:
diff changeset
64 -- the caller of the routine causing the write operation.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 procedure Cancel_Special_Output;
kono
parents:
diff changeset
67 -- Cancels the effect of a call to Set_Special_Output, if any. The output
kono
parents:
diff changeset
68 -- is then directed to standard error or standard output depending on the
kono
parents:
diff changeset
69 -- last call to Set_Standard_Error or Set_Standard_Output. It is never an
kono
parents:
diff changeset
70 -- error to call Cancel_Special_Output. It has the same effect as calling
kono
parents:
diff changeset
71 -- Set_Special_Output (null).
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Ignore_Output (S : String);
kono
parents:
diff changeset
74 -- Does nothing. To disable output, pass Ignore_Output'Access to
kono
parents:
diff changeset
75 -- Set_Special_Output.
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 procedure Set_Standard_Error;
kono
parents:
diff changeset
78 -- Sets subsequent output to appear on the standard error file (whatever
kono
parents:
diff changeset
79 -- that might mean for the host operating system, if anything) when
kono
parents:
diff changeset
80 -- no special output is in effect. When a special output is in effect,
kono
parents:
diff changeset
81 -- the output will appear on standard error only after special output
kono
parents:
diff changeset
82 -- has been cancelled.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 procedure Set_Standard_Output;
kono
parents:
diff changeset
85 -- Sets subsequent output to appear on the standard output file (whatever
kono
parents:
diff changeset
86 -- that might mean for the host operating system, if anything) when no
kono
parents:
diff changeset
87 -- special output is in effect. When a special output is in effect, the
kono
parents:
diff changeset
88 -- output will appear on standard output only after special output has been
kono
parents:
diff changeset
89 -- cancelled. Output to standard output is the default mode before any call
kono
parents:
diff changeset
90 -- to either of the Set procedures.
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 procedure Set_Output (FD : File_Descriptor);
kono
parents:
diff changeset
93 -- Sets subsequent output to appear on the given file descriptor when no
kono
parents:
diff changeset
94 -- special output is in effect. When a special output is in effect, the
kono
parents:
diff changeset
95 -- output will appear on the given file descriptor only after special
kono
parents:
diff changeset
96 -- output has been cancelled.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Indent;
kono
parents:
diff changeset
99 -- Increases the current indentation level. Whenever a line is written
kono
parents:
diff changeset
100 -- (triggered by Eol), an appropriate amount of whitespace is added to the
kono
parents:
diff changeset
101 -- beginning of the line, wrapping around if it gets too long.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Outdent;
kono
parents:
diff changeset
104 -- Decreases the current indentation level
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Write_Char (C : Character);
kono
parents:
diff changeset
107 -- Write one character to the standard output file. If the character is LF,
kono
parents:
diff changeset
108 -- this is equivalent to Write_Eol.
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 procedure Write_Erase_Char (C : Character);
kono
parents:
diff changeset
111 -- If last character in buffer matches C, erase it, otherwise no effect
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Write_Eol;
kono
parents:
diff changeset
114 -- Write an end of line (whatever is required by the system in use, e.g.
kono
parents:
diff changeset
115 -- CR/LF for DOS, or LF for Unix) to the standard output file. This routine
kono
parents:
diff changeset
116 -- also empties the line buffer, actually writing it to the file. Note that
kono
parents:
diff changeset
117 -- Write_Eol is the only routine that causes any actual output to be
kono
parents:
diff changeset
118 -- written. Trailing spaces are removed.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 procedure Write_Eol_Keep_Blanks;
kono
parents:
diff changeset
121 -- Similar as Write_Eol, except that trailing spaces are not removed
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Write_Int (Val : Int);
kono
parents:
diff changeset
124 -- Write an integer value with no leading blanks or zeroes. Negative values
kono
parents:
diff changeset
125 -- are preceded by a minus sign).
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 procedure Write_Spaces (N : Nat);
kono
parents:
diff changeset
128 -- Write N spaces
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure Write_Str (S : String);
kono
parents:
diff changeset
131 -- Write a string of characters to the standard output file. Note that
kono
parents:
diff changeset
132 -- end of line is normally handled separately using WRITE_EOL, but it is
kono
parents:
diff changeset
133 -- allowable for the string to contain LF (but not CR) characters, which
kono
parents:
diff changeset
134 -- are properly interpreted as end of line characters. The string may also
kono
parents:
diff changeset
135 -- contain horizontal tab characters.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure Write_Line (S : String);
kono
parents:
diff changeset
138 -- Equivalent to Write_Str (S) followed by Write_Eol;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 function Last_Char return Character;
kono
parents:
diff changeset
141 -- Returns last character written on the current line, or null if the
kono
parents:
diff changeset
142 -- current line is (so far) empty.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 procedure Delete_Last_Char;
kono
parents:
diff changeset
145 -- Deletes last character written on the current line, no effect if the
kono
parents:
diff changeset
146 -- current line is (so far) empty.
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 function Column return Pos;
kono
parents:
diff changeset
149 pragma Inline (Column);
kono
parents:
diff changeset
150 -- Returns the number of the column about to be written (e.g. a value of 1
kono
parents:
diff changeset
151 -- means the current line is empty).
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 -------------------------
kono
parents:
diff changeset
154 -- Buffer Save/Restore --
kono
parents:
diff changeset
155 -------------------------
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 -- This facility allows the current line buffer to be saved and restored
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 type Saved_Output_Buffer is private;
kono
parents:
diff changeset
160 -- Type used for Save/Restore_Buffer
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Buffer_Max : constant := Hostparm.Max_Line_Length;
kono
parents:
diff changeset
163 -- Maximal size of a buffered output line
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 function Save_Output_Buffer return Saved_Output_Buffer;
kono
parents:
diff changeset
166 -- Save current line buffer and reset line buffer to empty
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 procedure Restore_Output_Buffer (S : Saved_Output_Buffer);
kono
parents:
diff changeset
169 -- Restore previously saved output buffer. The value in S is not affected
kono
parents:
diff changeset
170 -- so it is legitimate to restore a buffer more than once.
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 --------------------------
kono
parents:
diff changeset
173 -- Debugging Procedures --
kono
parents:
diff changeset
174 --------------------------
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 -- The following procedures are intended only for debugging purposes,
kono
parents:
diff changeset
177 -- for temporary insertion into the text in environments where a debugger
kono
parents:
diff changeset
178 -- is not available. They all have non-standard very short lower case
kono
parents:
diff changeset
179 -- names, precisely to make sure that they are only used for debugging.
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure w (C : Character);
kono
parents:
diff changeset
182 -- Dump quote, character, quote, followed by line return
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 procedure w (S : String);
kono
parents:
diff changeset
185 -- Dump string followed by line return
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 procedure w (V : Int);
kono
parents:
diff changeset
188 -- Dump integer followed by line return
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 procedure w (B : Boolean);
kono
parents:
diff changeset
191 -- Dump Boolean followed by line return
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 procedure w (L : String; C : Character);
kono
parents:
diff changeset
194 -- Dump contents of string followed by blank, quote, character, quote
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 procedure w (L : String; S : String);
kono
parents:
diff changeset
197 -- Dump two strings separated by blanks, followed by line return
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 procedure w (L : String; V : Int);
kono
parents:
diff changeset
200 -- Dump contents of string followed by blank, integer, line return
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 procedure w (L : String; B : Boolean);
kono
parents:
diff changeset
203 -- Dump contents of string followed by blank, Boolean, line return
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 private
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 type Saved_Output_Buffer is record
kono
parents:
diff changeset
208 Buffer : String (1 .. Buffer_Max + 1);
kono
parents:
diff changeset
209 Next_Col : Positive;
kono
parents:
diff changeset
210 Cur_Indentation : Natural;
kono
parents:
diff changeset
211 end record;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 end Output;