1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
29 package body Sinput
.P
is
31 First
: Boolean := True;
32 -- Flag used when Load_Project_File is called the first time,
33 -- to set Main_Source_File.
34 -- The flag is reset to False at the first call to Load_Project_File.
35 -- Calling Reset_First sets it back to True.
37 -----------------------
38 -- Load_Project_File --
39 -----------------------
41 function Load_Project_File
(Path
: String) return Source_File_Index
is
42 X
: Source_File_Index
;
45 X
:= Sinput
.C
.Load_File
(Path
);
48 Main_Source_File
:= X
;
53 end Load_Project_File
;
59 procedure Reset_First
is
64 --------------------------------
65 -- Restore_Project_Scan_State --
66 --------------------------------
68 procedure Restore_Project_Scan_State
69 (Saved_State
: Saved_Project_Scan_State
)
72 Restore_Scan_State
(Saved_State
.Scan_State
);
73 Source
:= Saved_State
.Source
;
74 Current_Source_File
:= Saved_State
.Current_Source_File
;
75 end Restore_Project_Scan_State
;
77 -----------------------------
78 -- Save_Project_Scan_State --
79 -----------------------------
81 procedure Save_Project_Scan_State
82 (Saved_State
: out Saved_Project_Scan_State
)
85 Save_Scan_State
(Saved_State
.Scan_State
);
86 Saved_State
.Source
:= Source
;
87 Saved_State
.Current_Source_File
:= Current_Source_File
;
88 end Save_Project_Scan_State
;
90 ----------------------------
91 -- Source_File_Is_Subunit --
92 ----------------------------
94 function Source_File_Is_Subunit
(X
: Source_File_Index
) return Boolean is
96 Prj
.Err
.Scanner
.Initialize_Scanner
(X
);
98 -- We scan past junk to the first interesting compilation unit
99 -- token, to see if it is SEPARATE. We ignore WITH keywords during
100 -- this and also PRIVATE. The reason for ignoring PRIVATE is that
101 -- it handles some error situations, and also to handle PRIVATE WITH
104 while Token
= Tok_With
105 or else Token
= Tok_Private
106 or else (Token
not in Token_Class_Cunit
and then Token
/= Tok_EOF
)
108 Prj
.Err
.Scanner
.Scan
;
111 return Token
= Tok_Separate
;
112 end Source_File_Is_Subunit
;