OSDN Git Service

2009-08-17 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / tree_io.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              T R E E _ I O                               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2009, 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.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- GNAT was originally developed  by the GNAT team at  New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
29 --                                                                          --
30 ------------------------------------------------------------------------------
31
32 --  This package contains the routines used to read and write the tree files
33 --  used by ASIS. Only the actual read and write routines are here. The open,
34 --  create and close routines are elsewhere (in Osint in the compiler, and in
35 --  the tree read driver for the tree read interface).
36
37 with Types; use Types;
38
39 with System;        use System;
40 with System.OS_Lib; use System.OS_Lib;
41
42 package Tree_IO is
43
44    Tree_Format_Error : exception;
45    --  Raised if a format error is detected in the input file
46
47    ASIS_Version_Number : constant := 23;
48    --  ASIS Version. This is used to check for consistency between the compiler
49    --  used to generate trees and an ASIS application that is reading the
50    --  trees. It must be incremented whenever a change is made to the tree
51    --  format that would result in the compiler being incompatible with an
52    --  older version of ASIS.
53
54    procedure Tree_Read_Initialize (Desc : File_Descriptor);
55    --  Called to initialize reading of a tree file. This call must be made
56    --  before calls to Tree_Read_xx. No calls to Tree_Write_xx are permitted
57    --  after this call.
58
59    procedure Tree_Read_Data (Addr : Address; Length : Int);
60    --  Checks that the Length provided is the same as what has been provided
61    --  to the corresponding Tree_Write_Data from the current tree file,
62    --  Tree_Format_Error is raised if it is not the case. If Length is
63    --  correct and non zero, reads Length bytes of information into memory
64    --  starting at Addr from the current tree file.
65
66    procedure Tree_Read_Bool (B : out Boolean);
67    --  Reads a single boolean value. The boolean value must have been written
68    --  with a call to the Tree_Write_Bool procedure.
69
70    procedure Tree_Read_Char (C : out Character);
71    --  Reads a single character. The character must have been written with a
72    --  call to the Tree_Write_Char procedure.
73
74    procedure Tree_Read_Int (N : out Int);
75    --  Reads a single integer value. The integer must have been written with
76    --  a call to the Tree_Write_Int procedure.
77
78    procedure Tree_Read_Str (S : out String_Ptr);
79    --  Read string, allocate on heap, and return pointer to allocated string
80    --  which always has a lower bound of 1.
81
82    procedure Tree_Read_Terminate;
83    --  Called after reading all data, checks that the buffer pointers is at
84    --  the end of file, raising Tree_Format_Error if not.
85
86    procedure Tree_Write_Initialize (Desc : File_Descriptor);
87    --  Called to initialize writing of a tree file. This call must be made
88    --  before calls to Tree_Write_xx. No calls to Tree_Read_xx are permitted
89    --  after this call.
90
91    procedure Tree_Write_Data (Addr : Address; Length : Int);
92    --  Writes Length then, if Length is not null, Length bytes of data
93    --  starting at Addr to current tree file
94
95    procedure Tree_Write_Bool (B : Boolean);
96    --  Writes a single boolean value to the current tree file
97
98    procedure Tree_Write_Char (C : Character);
99    --  Writes a single character to the current tree file
100
101    procedure Tree_Write_Int (N : Int);
102    --  Writes a single integer value to the current tree file
103
104    procedure Tree_Write_Str (S : String_Ptr);
105    --  Write out string value referenced by S (low bound of S must be 1)
106
107    procedure Tree_Write_Terminate;
108    --  Terminates writing of the file (flushing the buffer), but does not
109    --  close the file (the caller is responsible for closing the file).
110
111 end Tree_IO;