home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
gnat-2.06-src.tgz
/
tar.out
/
fsf
/
gnat
/
ada
/
inline.ads
< prev
next >
Wrap
Text File
|
1996-09-28
|
5KB
|
104 lines
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I N L I N E --
-- --
-- S p e c --
-- --
-- $Revision: 1.1 $ --
-- --
-- Copyright (c) 1992,1993,1994,1995 NYU, All Rights Reserved --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- This module handles two kinds of inlining activity:
-- a) Instantiation of generic bodies. This is done unconditionally, after
-- analysis and expansion of the main unit.
-- b) Compilation of unit bodies that contain the bodies of inlined sub-
-- programs. This is done only if inlining is enabled (-gnatn). Full inlining
-- requires that a) an b) be mutually recursive, because each step may
-- generate another generic expansion and further inlined calls. For now each
-- of them uses a workpile algorithm, but they are called independently from
-- Frontend, and thus are not mutually recursive.
with Opt; use Opt;
with Snames; use Snames;
with Table;
with Types; use Types;
package Inline is
------------------------
-- Body Instantiation --
------------------------
-- The bodies of generic instantiations are built after semantic analysis
-- of the main unit is complete. Generic instantiations are saved in a
-- global data structure, and the bodies constructed by means of a separate
-- analysis and expansion step.
type Pending_Body_Info is record
Inst_Node : Node_Id;
Act_Decl : Node_Id;
end record;
package Pending_Instantiations is new Table (
Table_Component_Type => Pending_Body_Info,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Sem.Pending_Instantiations");
--------------------
-- Inlined Bodies --
--------------------
-- Inlined functions are actually placed in line by the backend if the
-- corresponding bodies are available (i.e. compiled). Whenever we find
-- a call to an inlined subprogram, we add the name of the enclosing
-- compilation unit to a worklist. After all compilation, and after
-- expansion of generic bodies, we traverse the list of pending bodies
-- and compile them as well.
package Inlined_Bodies is new Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Sem.Inlined_Bodies");
-----------------
-- Subprograms --
-----------------
procedure Instantiate_Bodies;
-- This procedure is called after semantic analysis is complete, to
-- instantiate the bodies of generic instantiations that appear in the
-- compilation unit.
procedure Add_Inlined_Body (N : Node_Id; E : Entity_Id);
-- N is a procedure or function call, and E is the called entity, which
-- is an inlined subprogram. Add E's enclosing unit to Inlined_Bodies
-- so that body of E can be subsequently retrieved and analyzed.
procedure Analyze_Inlined_Bodies;
-- At end of compilation, analyze the bodies of all units that contain
-- inlined subprograms that are actually called.
end Inline;