10. Processing an Ada Library by an ASIS-Based Tool¶
When an Ada unit to be processed by some ASIS-based tool makes use of an Ada library, you need to be aware of the following features of using Ada libraries with GNAT:
An Ada library is a collection of precompiled Ada components. The sources of the Ada components belonging to the library are present, but if your program uses some components from a library, these components are not recompiled by gnatmake (except in circumstances described below). For example,
Ada.Text_IOis not recompiled when you invoke gnatmake on a unit that
According to the GNAT source-based compilation model, the spec of a library component is processed when an application unit depending on such a component is compiled, but the body of the library component is not processed. As a result, if you invoke gnatmake to create a set of tree files covering a given program, and if this program references an entity from an Ada library, then the set of tree files created by such a call will contain only specs, but not bodies for library components.
Any GNAT installation contains the GNAT Run-Time Library (RTL) as a precompiled Ada library. In some cases, a GNAT installation may contain some other libraries (such as Win32Ada Binding on a Windows GNAT platform).
In ASIS-for-GNAT, there is no standard way to define whether a given
Compilation_Unitbelongs to some precompiled Ada library other than the GNAT Run-Time Library (some heuristics may be added to
Asis.Extensions). ASIS-for-GNAT classifies (by means of the
Asis.Compilation_Units.Unit_Originquery) a unit as
A_Predefined_Unit, if it is from the Run-Time Library and if it is mentioned in the Ada Reference Manual, Annex A, Paragraph 2 as an Ada 95 predefined unit; a unit is classified as
An_Implementation_Unitif is belongs to Run-Time Library but is not mentioned in the paragraph just cited. Components of Ada libraries other than the Run-Time Library are always classified as
It is possible to recompile the components of the Ada libraries used by a given program. To do this, you have to invoke
gnatmakefor this program with the
-aoption. If you create a set of tree files for your program by invoking gnatmake with the
-aoption, the resulting set of tree files will contain all the units needed by this program to make up a complete partition.
Therefore, there are two possibilities for an ASIS-based tool if processing (or avoiding processing) of Ada libraries is important for the functionality of the tool:
If the tool is not to process components of Ada libraries, then a set of tree files for this tool may be created by invoking gnatmake without the
-aoption (this is the usual way of using gnatmake). When the tool encounters a
Compilation_Unitwhich represents a spec of some library unit, and for which
Asis.Compilation_Units.Corresponding_Bodyyields a result of
A_Nonexistent_Bodykind, then the tool may conclude that this library unit belongs to some precompiled Ada library.
If a tool needs to process all the Ada compilation units making up a program, then a set of tree files for this program should be created by invoking gnatmake with the
You can use
to filter out Run-Time Library components.