aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-24 18:37:53 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-24 21:14:11 +0200
commit37d33fb7b2f43e275a98d22561080758fcdfc601 (patch)
tree8062ee7a9c9a2970814d33a7ca1d39b82c47d5f3
parent9c4bbedd7baf23e491e52361643c308623bba1f3 (diff)
downloadghdl-37d33fb7b2f43e275a98d22561080758fcdfc601.tar.gz
ghdl-37d33fb7b2f43e275a98d22561080758fcdfc601.tar.bz2
ghdl-37d33fb7b2f43e275a98d22561080758fcdfc601.zip
libraries: add Get_Library_No_Create.
-rw-r--r--src/libraries.adb24
-rw-r--r--src/libraries.ads4
2 files changed, 18 insertions, 10 deletions
diff --git a/src/libraries.adb b/src/libraries.adb
index 15b0fd3bc..30128749d 100644
--- a/src/libraries.adb
+++ b/src/libraries.adb
@@ -716,11 +716,8 @@ package body Libraries is
Set_Visible_Flag (Work_Library, True);
end Load_Work_Library;
- -- Get or create a library from an identifier.
- function Get_Library (Ident: Name_Id; Loc : Location_Type)
- return Iir_Library_Declaration
- is
- Library: Iir_Library_Declaration;
+ function Get_Library_No_Create (Ident : Name_Id)
+ return Iir_Library_Declaration is
begin
-- The library work is a little bit special.
if Ident = Std_Names.Name_Work or else Ident = Work_Library_Name then
@@ -730,16 +727,23 @@ package body Libraries is
end if;
-- Check if the library has already been loaded.
- Library := Vhdl.Utils.Find_Name_In_Chain (Libraries_Chain, Ident);
+ return Vhdl.Utils.Find_Name_In_Chain (Libraries_Chain, Ident);
+ end Get_Library_No_Create;
+
+ -- Get or create a library from an identifier.
+ function Get_Library (Ident: Name_Id; Loc : Location_Type)
+ return Iir_Library_Declaration
+ is
+ Library: Iir_Library_Declaration;
+ begin
+ Library := Get_Library_No_Create (Ident);
if Library /= Null_Iir then
return Library;
end if;
-- This is a new library.
- if Ident = Std_Names.Name_Std then
- -- Load_std_library must have been called before.
- raise Internal_Error;
- end if;
+ -- Load_std_library must have been called before.
+ pragma Assert (Ident /= Std_Names.Name_Std);
Library := Create_Iir (Iir_Kind_Library_Declaration);
Set_Location (Library, Library_Location);
diff --git a/src/libraries.ads b/src/libraries.ads
index 900cb67cf..396ba8885 100644
--- a/src/libraries.ads
+++ b/src/libraries.ads
@@ -107,6 +107,10 @@ package Libraries is
function Find_Primary_Unit
(Library: Iir_Library_Declaration; Name: Name_Id) return Iir_Design_Unit;
+ -- Get the library named IDENT. Return Null_Iir if it doesn't exist.
+ function Get_Library_No_Create (Ident : Name_Id)
+ return Iir_Library_Declaration;
+
-- Get or create a library from an identifier.
-- LOC is used only to report errors.
function Get_Library (Ident : Name_Id; Loc : Location_Type)