| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- G E N _ I L -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2020-2025, 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 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
pragma Warnings (Off); -- with clauses for children |
| 27 |
with Ada.Characters.Handling; use Ada.Characters.Handling; |
| 28 |
with Ada.Streams.Stream_IO; |
| 29 |
pragma Warnings (On); |
| 30 |
|
| 31 |
package Gen_IL is -- generate intermediate language |
| 32 |
|
| 33 |
-- This package and children generates the main intermediate language used |
| 34 |
-- by the GNAT compiler, which is a decorated syntax tree. |
| 35 |
|
| 36 |
-- The generated Ada packages are: |
| 37 |
-- |
| 38 |
-- Seinfo |
| 39 |
-- Sinfo.Nodes |
| 40 |
-- Einfo.Entities |
| 41 |
-- Nmake |
| 42 |
-- Seinfo_Tables |
| 43 |
-- |
| 44 |
-- We also generate C code: |
| 45 |
-- |
| 46 |
-- einfo.h |
| 47 |
-- sinfo.h |
| 48 |
-- snames.h |
| 49 |
-- |
| 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. |
| 53 |
-- |
| 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 |
| 59 |
-- thing. |
| 60 |
|
| 61 |
-- Misc declarations used throughout: |
| 62 |
|
| 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 |
| 67 |
-- blank. |
| 68 |
|
| 69 |
subtype Root_Nat is Root_Int range 0 .. Root_Int'Last; |
| 70 |
subtype Root_Pos is Root_Int range 1 .. Root_Int'Last; |
| 71 |
|
| 72 |
function Capitalize (S : String) return String; |
| 73 |
procedure Capitalize (S : in out String); |
| 74 |
-- Turns an identifier into Mixed_Case |
| 75 |
|
| 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. |
| 79 |
|
| 80 |
type Sink is record |
| 81 |
File : Ada.Streams.Stream_IO.File_Type; |
| 82 |
Indent : Natural; |
| 83 |
New_Line : Boolean; |
| 84 |
end record; |
| 85 |
|
| 86 |
procedure Create_File (Buffer : in out Sink; Name : String); |
| 87 |
|
| 88 |
procedure Increase_Indent (Buffer : in out Sink; Amount : Natural); |
| 89 |
|
| 90 |
procedure Decrease_Indent (Buffer : in out Sink; Amount : Natural); |
| 91 |
|
| 92 |
procedure Put (Buffer : in out Sink; Item : String); |
| 93 |
|
| 94 |
LF : constant String := "" & ASCII.LF; |
| 95 |
|
| 96 |
end Gen_IL; |