1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
31 package body Sinput.P is
33 First : Boolean := True;
34 -- Flag used when Load_Project_File is called the first time,
35 -- to set Main_Source_File.
36 -- The flag is reset to False at the first call to Load_Project_File
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;
56 --------------------------------
57 -- Restore_Project_Scan_State --
58 --------------------------------
60 procedure Restore_Project_Scan_State
61 (Saved_State : in Saved_Project_Scan_State)
64 Restore_Scan_State (Saved_State.Scan_State);
65 Source := Saved_State.Source;
66 Current_Source_File := Saved_State.Current_Source_File;
67 end Restore_Project_Scan_State;
69 -----------------------------
70 -- Save_Project_Scan_State --
71 -----------------------------
73 procedure Save_Project_Scan_State
74 (Saved_State : out Saved_Project_Scan_State)
77 Save_Scan_State (Saved_State.Scan_State);
78 Saved_State.Source := Source;
79 Saved_State.Current_Source_File := Current_Source_File;
80 end Save_Project_Scan_State;
82 ----------------------------
83 -- Source_File_Is_Subunit --
84 ----------------------------
86 function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is
88 Prj.Err.Scanner.Initialize_Scanner (No_Unit, X);
90 -- We scan past junk to the first interesting compilation unit
91 -- token, to see if it is SEPARATE. We ignore WITH keywords during
92 -- this and also PRIVATE. The reason for ignoring PRIVATE is that
93 -- it handles some error situations, and also it is possible that
94 -- a PRIVATE WITH feature might be approved some time in the future.
96 while Token = Tok_With
97 or else Token = Tok_Private
98 or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF)
103 return Token = Tok_Separate;
104 end Source_File_Is_Subunit;