From 37d33fb7b2f43e275a98d22561080758fcdfc601 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 24 Jun 2019 18:37:53 +0200 Subject: libraries: add Get_Library_No_Create. --- src/libraries.adb | 24 ++++++++++++++---------- src/libraries.ads | 4 ++++ 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) -- cgit v1.2.3