1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2020-2023, 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 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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 pragma Warnings
(Off
); -- with clauses for children
27 with Ada
.Characters
.Handling
; use Ada
.Characters
.Handling
;
28 with Ada
.Streams
.Stream_IO
;
31 package Gen_IL
is -- generate intermediate language
33 -- This package and children generates the main intermediate language used
34 -- by the GNAT compiler, which is a decorated syntax tree.
36 -- The generated Ada packages are:
44 -- We also generate C code:
50 -- It is necessary to look at this generated code in order to understand
51 -- the compiler. In addition, it is necessary to look at comments in the
52 -- spec and body of Gen_IL.
54 -- Note that the Gen_IL "compiler" and the GNAT Ada compiler are separate
55 -- programs, with no dependencies between them in either direction. That
56 -- is, Gen_IL does not say "with" of GNAT units, and GNAT does not say
57 -- "with Gen_IL". There are many things declared in Gen_IL and GNAT with
58 -- the same name; these are typically related, but they are not the same
61 -- Misc declarations used throughout:
63 type Root_Int
is new Integer;
64 function Image
(X
: Root_Int
) return String;
65 -- Without the extra blank. You can derive from Root_Int or the subtypes
66 -- below, and inherit a convenient Image function that leaves out that
69 subtype Root_Nat
is Root_Int
range 0 .. Root_Int
'Last;
70 subtype Root_Pos
is Root_Int
range 1 .. Root_Int
'Last;
72 function Capitalize
(S
: String) return String;
73 procedure Capitalize
(S
: in out String);
74 -- Turns an identifier into Mixed_Case
76 -- The following declares a minimal implementation of formatted output
77 -- that is piggybacked on Ada.Streams.Stream_IO for bootstrap reasons.
78 -- It uses LF as universal line terminator to make it host independent.
81 File
: Ada
.Streams
.Stream_IO
.File_Type
;
86 procedure Create_File
(Buffer
: in out Sink
; Name
: String);
88 procedure Increase_Indent
(Buffer
: in out Sink
; Amount
: Natural);
90 procedure Decrease_Indent
(Buffer
: in out Sink
; Amount
: Natural);
92 procedure Put
(Buffer
: in out Sink
; Item
: String);
94 LF
: constant String := "" & ASCII
.LF
;