1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2001 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 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package contains low level output routines used by the compiler
35 -- for writing error messages and informational output. It is also used
36 -- by the debug source file output routines (see Sprintf.Print_Eol).
38 with Types
; use Types
;
41 pragma Elaborate_Body
(Output
);
43 type Output_Proc
is access procedure (S
: String);
44 -- This type is used for the Set_Special_Output procedure. If this
45 -- procedure is called, then instead of lines being written to
46 -- standard error or standard output, a call is made to the given
47 -- procedure for each line, passing the line with an end of line
48 -- character (which is a single ASCII.LF character, even in systems
49 -- which normally use CR/LF or some other sequence for line end).
55 procedure Set_Special_Output
(P
: Output_Proc
);
56 -- Sets subsequent output to call procedure P. If P is null, then
57 -- the call cancels the effect of a previous call, reverting the
58 -- output to standard error or standard output depending on the
59 -- mode at the time of previous call. Any exception generated by
60 -- by calls to P is simply propagated to the caller of the routine
61 -- causing the write operation.
63 procedure Cancel_Special_Output
;
64 -- Cancels the effect of a call to Set_Special_Output, if any.
65 -- The output is then directed to standard error or standard output
66 -- depending on the last call to Set_Standard_Error or Set_Standard_Output.
67 -- It is never an error to call Cancel_Special_Output. It has the same
68 -- effect as calling Set_Special_Output (null).
70 procedure Set_Standard_Error
;
71 -- Sets subsequent output to appear on the standard error file (whatever
72 -- that might mean for the host operating system, if anything) when
73 -- no special output is in effect. When a special output is in effect,
74 -- the output will appear on standard error only after special output
75 -- has been cancelled.
77 procedure Set_Standard_Output
;
78 -- Sets subsequent output to appear on the standard output file (whatever
79 -- that might mean for the host operating system, if anything) when
80 -- no special output is in effect. When a special output is in effect,
81 -- the output will appear on standard output only after special output
82 -- has been cancelled. Output to standard output is the default mode
83 -- before any call to either of the Set procedures.
85 procedure Write_Char
(C
: Character);
86 -- Write one character to the standard output file. Note that the
87 -- character should not be LF or CR (use Write_Eol for end of line)
90 -- Write an end of line (whatever is required by the system in use,
91 -- e.g. CR/LF for DOS, or LF for Unix) to the standard output file.
92 -- This routine also empties the line buffer, actually writing it
93 -- to the file. Note that Write_Eol is the only routine that causes
94 -- any actual output to be written.
96 procedure Write_Int
(Val
: Int
);
97 -- Write an integer value with no leading blanks or zeroes. Negative
98 -- values are preceded by a minus sign).
100 procedure Write_Str
(S
: String);
101 -- Write a string of characters to the standard output file. Note that
102 -- end of line is handled separately using WRITE_EOL, so the string
103 -- should not contain either of the characters LF or CR, but it may
104 -- contain horizontal tab characters.
106 procedure Write_Line
(S
: String);
107 -- Equivalent to Write_Str (S) followed by Write_Eol;
109 function Column
return Nat
;
110 pragma Inline
(Column
);
111 -- Returns the number of the column about to be written (e.g. a value
112 -- of 1 means the current line is empty).
114 --------------------------
115 -- Debugging Procedures --
116 --------------------------
118 -- The following procedures are intended only for debugging purposes,
119 -- for temporary insertion into the text in environments where a debugger
120 -- is not available. They all have non-standard very short lower case
121 -- names, precisely to make sure that they are only used for debugging!
123 procedure w
(C
: Character);
124 -- Dump quote, character quote, followed by line return
126 procedure w
(S
: String);
127 -- Dump string followed by line return
129 procedure w
(V
: Int
);
130 -- Dump integer followed by line return
132 procedure w
(B
: Boolean);
133 -- Dump Boolean followed by line return
135 procedure w
(L
: String; C
: Character);
136 -- Dump contents of string followed by blank, quote, character, quote
138 procedure w
(L
: String; S
: String);
139 -- Dump two strings separated by blanks, followed by line return
141 procedure w
(L
: String; V
: Int
);
142 -- Dump contents of string followed by blank, integer, line return
144 procedure w
(L
: String; B
: Boolean);
145 -- Dump contents of string followed by blank, Boolean, line return