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 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 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
30 package body Sinput.P is
32 First : Boolean := True;
33 -- Flag used when Load_Project_File is called the first time,
34 -- to set Main_Source_File.
35 -- The flag is reset to False at the first call to Load_Project_File.
36 -- Calling Reset_First sets it back to True.
38 -----------------------
39 -- Load_Project_File --
40 -----------------------
42 function Load_Project_File (Path : String) return Source_File_Index is
43 X : Source_File_Index;
46 X := Sinput.C.Load_File (Path);
49 Main_Source_File := X;
54 end Load_Project_File;
60 procedure Reset_First is
65 --------------------------------
66 -- Restore_Project_Scan_State --
67 --------------------------------
69 procedure Restore_Project_Scan_State
70 (Saved_State : Saved_Project_Scan_State)
73 Restore_Scan_State (Saved_State.Scan_State);
74 Source := Saved_State.Source;
75 Current_Source_File := Saved_State.Current_Source_File;
76 end Restore_Project_Scan_State;
78 -----------------------------
79 -- Save_Project_Scan_State --
80 -----------------------------
82 procedure Save_Project_Scan_State
83 (Saved_State : out Saved_Project_Scan_State)
86 Save_Scan_State (Saved_State.Scan_State);
87 Saved_State.Source := Source;
88 Saved_State.Current_Source_File := Current_Source_File;
89 end Save_Project_Scan_State;
91 ----------------------------
92 -- Source_File_Is_Subunit --
93 ----------------------------
95 function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is
97 Prj.Err.Scanner.Initialize_Scanner (X);
99 -- We scan past junk to the first interesting compilation unit
100 -- token, to see if it is SEPARATE. We ignore WITH keywords during
101 -- this and also PRIVATE. The reason for ignoring PRIVATE is that
102 -- it handles some error situations, and also to handle PRIVATE WITH
105 while Token = Tok_With
106 or else Token = Tok_Private
107 or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF)
109 Prj.Err.Scanner.Scan;
112 return Token = Tok_Separate;
113 end Source_File_Is_Subunit;