aboutsummaryrefslogtreecommitdiffstats
path: root/src/ghdldrv
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-09-30 06:22:36 +0200
committerTristan Gingold <tgingold@free.fr>2017-10-02 20:49:37 +0200
commita546bd6c27f974b85ad2a36ac6b96fa5916b3be2 (patch)
tree406f79eb3bb89d163457706cf6dc158577e9f736 /src/ghdldrv
parente2b71f93c9a6fda2d8450f1c096f5c9b8eec910c (diff)
downloadghdl-a546bd6c27f974b85ad2a36ac6b96fa5916b3be2.tar.gz
ghdl-a546bd6c27f974b85ad2a36ac6b96fa5916b3be2.tar.bz2
ghdl-a546bd6c27f974b85ad2a36ac6b96fa5916b3be2.zip
ghdlcomp: add compile_analyze_file2.
Diffstat (limited to 'src/ghdldrv')
-rw-r--r--src/ghdldrv/ghdlcomp.adb48
-rw-r--r--src/ghdldrv/ghdlcomp.ads2
2 files changed, 49 insertions, 1 deletions
diff --git a/src/ghdldrv/ghdlcomp.adb b/src/ghdldrv/ghdlcomp.adb
index 19f76c7ed..9b45584d2 100644
--- a/src/ghdldrv/ghdlcomp.adb
+++ b/src/ghdldrv/ghdlcomp.adb
@@ -23,7 +23,6 @@ with Ada.Characters.Latin_1;
with Ada.Text_IO;
with Types;
-with Iirs; use Iirs;
with Flags;
with Sem;
with Name_Table;
@@ -205,6 +204,53 @@ package body Ghdlcomp is
end loop;
end Compile_Analyze_File;
+ function Compile_Analyze_File2 (File : String) return Iir
+ is
+ use Types;
+ Id : constant Name_Id := Name_Table.Get_Identifier (File);
+ Design_File : Iir_Design_File;
+ New_Design_File : Iir_Design_File;
+ Unit : Iir;
+ Next_Unit : Iir;
+ begin
+ Design_File := Libraries.Load_File (Id);
+ if Design_File = Null_Iir or else Errorout.Nbr_Errors > 0 then
+ -- Stop now in case of error (file not found or parse error).
+ return Design_File;
+ end if;
+
+ Unit := Get_First_Design_Unit (Design_File);
+ while Unit /= Null_Iir loop
+ Libraries.Finish_Compilation (Unit, True);
+
+ Next_Unit := Get_Chain (Unit);
+
+ if Errorout.Nbr_Errors = 0 then
+ Set_Chain (Unit, Null_Iir);
+ Libraries.Add_Design_Unit_Into_Library (Unit);
+ New_Design_File := Get_Design_File (Unit);
+ end if;
+
+ Unit := Next_Unit;
+ end loop;
+
+ if Errorout.Nbr_Errors > 0 then
+ return Design_File;
+ end if;
+
+ Free_Iir (Design_File);
+
+ -- Do late analysis checks.
+ Unit := Get_First_Design_Unit (New_Design_File);
+ while Unit /= Null_Iir loop
+ Sem.Sem_Analysis_Checks_List
+ (Unit, Is_Warning_Enabled (Warnid_Delayed_Checks));
+ Unit := Get_Chain (Unit);
+ end loop;
+
+ return New_Design_File;
+ end Compile_Analyze_File2;
+
procedure Compile_Elaborate (Unit_Name : String_Access)
is
Run_Arg : Natural;
diff --git a/src/ghdldrv/ghdlcomp.ads b/src/ghdldrv/ghdlcomp.ads
index 88e8af20f..487f70fc1 100644
--- a/src/ghdldrv/ghdlcomp.ads
+++ b/src/ghdldrv/ghdlcomp.ads
@@ -16,6 +16,7 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with GNAT.OS_Lib; use GNAT.OS_Lib;
+with Iirs; use Iirs;
package Ghdlcomp is
-- This procedure is called at start of commands which call
@@ -72,6 +73,7 @@ package Ghdlcomp is
-- Must be first initialized by Compile_Init
procedure Compile_Analyze_Init (Load_Work : Boolean := True);
procedure Compile_Analyze_File (File : String);
+ function Compile_Analyze_File2 (File : String) return Iir;
procedure Compile_Elaborate (Unit_Name : String_Access);
procedure Compile_Run;
end Ghdlcomp;