OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [output.ads] - Blame information for rev 706

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.