1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2008, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package contains the routines used to read and write the tree files
35 -- used by ASIS. Only the actual read and write routines are here. The open,
36 -- create and close routines are elsewhere (in Osint in the compiler, and in
37 -- the tree read driver for the tree read interface).
39 with Types
; use Types
;
41 with System
; use System
;
42 with System
.OS_Lib
; use System
.OS_Lib
;
46 Tree_Format_Error
: exception;
47 -- Raised if a format error is detected in the input file
49 ASIS_Version_Number
: constant := 22;
50 -- ASIS Version. This is used to check for consistency between the compiler
51 -- used to generate trees and an ASIS application that is reading the
52 -- trees. It must be incremented whenever a change is made to the tree
53 -- format that would result in the compiler being incompatible with an
54 -- older version of ASIS.
56 procedure Tree_Read_Initialize
(Desc
: File_Descriptor
);
57 -- Called to initialize reading of a tree file. This call must be made
58 -- before calls to Tree_Read_xx. No calls to Tree_Write_xx are permitted
61 procedure Tree_Read_Data
(Addr
: Address
; Length
: Int
);
62 -- Checks that the Length provided is the same as what has been provided
63 -- to the corresponding Tree_Write_Data from the current tree file,
64 -- Tree_Format_Error is raised if it is not the case. If Length is
65 -- correct and non zero, reads Length bytes of information into memory
66 -- starting at Addr from the current tree file.
68 procedure Tree_Read_Bool
(B
: out Boolean);
69 -- Reads a single boolean value. The boolean value must have been written
70 -- with a call to the Tree_Write_Bool procedure.
72 procedure Tree_Read_Char
(C
: out Character);
73 -- Reads a single character. The character must have been written with a
74 -- call to the Tree_Write_Char procedure.
76 procedure Tree_Read_Int
(N
: out Int
);
77 -- Reads a single integer value. The integer must have been written with
78 -- a call to the Tree_Write_Int procedure.
80 procedure Tree_Read_Str
(S
: out String_Ptr
);
81 -- Read string, allocate on heap, and return pointer to allocated string
82 -- which always has a lower bound of 1.
84 procedure Tree_Read_Terminate
;
85 -- Called after reading all data, checks that the buffer pointers is at
86 -- the end of file, raising Tree_Format_Error if not.
88 procedure Tree_Write_Initialize
(Desc
: File_Descriptor
);
89 -- Called to initialize writing of a tree file. This call must be made
90 -- before calls to Tree_Write_xx. No calls to Tree_Read_xx are permitted
93 procedure Tree_Write_Data
(Addr
: Address
; Length
: Int
);
94 -- Writes Length then, if Length is not null, Length bytes of data
95 -- starting at Addr to current tree file
97 procedure Tree_Write_Bool
(B
: Boolean);
98 -- Writes a single boolean value to the current tree file
100 procedure Tree_Write_Char
(C
: Character);
101 -- Writes a single character to the current tree file
103 procedure Tree_Write_Int
(N
: Int
);
104 -- Writes a single integer value to the current tree file
106 procedure Tree_Write_Str
(S
: String_Ptr
);
107 -- Write out string value referenced by S (low bound of S must be 1)
109 procedure Tree_Write_Terminate
;
110 -- Terminates writing of the file (flushing the buffer), but does not
111 -- close the file (the caller is responsible for closing the file).