aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/sem_lib.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-11-25 20:07:00 +0100
committerTristan Gingold <tgingold@free.fr>2018-11-26 20:19:15 +0100
commit44404214d370d226428e315da946d41ccf141507 (patch)
tree5741a66f5e0def695965664dbe0397e309a2cfad /src/vhdl/sem_lib.adb
parentd570ee98eaa200cc1bbf481035aa3bb1680504db (diff)
downloadghdl-44404214d370d226428e315da946d41ccf141507.tar.gz
ghdl-44404214d370d226428e315da946d41ccf141507.tar.bz2
ghdl-44404214d370d226428e315da946d41ccf141507.zip
Keep source file entry in design file to avoid searching the file.
Diffstat (limited to 'src/vhdl/sem_lib.adb')
-rw-r--r--src/vhdl/sem_lib.adb43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/vhdl/sem_lib.adb b/src/vhdl/sem_lib.adb
index 0a6fce10d..5f1c0b367 100644
--- a/src/vhdl/sem_lib.adb
+++ b/src/vhdl/sem_lib.adb
@@ -53,6 +53,7 @@ package body Sem_Lib is
if Res /= Null_Iir then
Set_Parent (Res, Work_Library);
Set_Design_File_Filename (Res, Files_Map.Get_File_Name (File));
+ Set_Design_File_Source (Res, File);
end if;
return Res;
end Load_File;
@@ -159,41 +160,45 @@ package body Sem_Lib is
procedure Load_Parse_Design_Unit (Design_Unit: Iir_Design_Unit; Loc : Iir)
is
use Scanner;
+ Design_File : constant Iir_Design_File := Get_Design_File (Design_Unit);
+ Fe : Source_File_Entry;
Line, Off: Natural;
Pos: Source_Ptr;
Res: Iir;
- Design_File : Iir_Design_File;
- Fe : Source_File_Entry;
begin
-- The unit must not be loaded.
pragma Assert (Get_Date_State (Design_Unit) = Date_Disk);
- -- Load the file in memory.
- Design_File := Get_Design_File (Design_Unit);
- Fe := Files_Map.Read_Source_File
- (Get_Design_File_Directory (Design_File),
- Get_Design_File_Filename (Design_File));
+ Fe := Get_Design_File_Source (Design_File);
if Fe = No_Source_File_Entry then
- Error_Lib_Msg ("cannot load %n", +Get_Library_Unit (Design_Unit));
- raise Compilation_Error;
+ -- Load the file in memory.
+ Fe := Files_Map.Read_Source_File
+ (Get_Design_File_Directory (Design_File),
+ Get_Design_File_Filename (Design_File));
+ if Fe = No_Source_File_Entry then
+ Error_Lib_Msg ("cannot load %n", +Get_Library_Unit (Design_Unit));
+ raise Compilation_Error;
+ end if;
+ Set_Design_File_Source (Design_File, Fe);
+
+ -- Check if the file has changed.
+ if not Files_Map.Is_Eq
+ (Files_Map.Get_File_Checksum (Fe), Get_File_Checksum (Design_File))
+ then
+ Error_Msg_Sem (+Loc, "file %i has changed and must be reanalysed",
+ +Get_Design_File_Filename (Design_File));
+ raise Compilation_Error;
+ end if;
end if;
- Set_File (Fe);
- -- Check if the file has changed.
- if not Files_Map.Is_Eq
- (Files_Map.Get_File_Checksum (Get_Current_Source_File),
- Get_File_Checksum (Design_File))
- then
- Error_Msg_Sem (+Loc, "file %i has changed and must be reanalysed",
- +Get_Design_File_Filename (Design_File));
- raise Compilation_Error;
- elsif Get_Date (Design_Unit) = Date_Obsolete then
+ if Get_Date (Design_Unit) = Date_Obsolete then
Error_Msg_Sem (+Design_Unit, "%n has been obsoleted",
+Get_Library_Unit (Design_Unit));
raise Compilation_Error;
end if;
-- Set the position of the lexer
+ Set_File (Fe);
Pos := Get_Design_Unit_Source_Pos (Design_Unit);
Line := Natural (Get_Design_Unit_Source_Line (Design_Unit));
Off := Natural (Get_Design_Unit_Source_Col (Design_Unit));