6767from pyVHDLModel .Expression import UnaryExpression , BinaryExpression , TernaryExpression
6868from pyVHDLModel .Namespace import Namespace
6969from pyVHDLModel .Object import Obj , Signal , Constant , DeferredConstant
70- from pyVHDLModel .Symbol import AllPackageMembersReferenceSymbol , PackageMemberReferenceSymbol , SimpleObjectOrFunctionCallSymbol
70+ from pyVHDLModel .Symbol import PackageReferenceSymbol , AllPackageMembersReferenceSymbol , PackageMemberReferenceSymbol , SimpleObjectOrFunctionCallSymbol
7171from pyVHDLModel .Concurrent import EntityInstantiation , ComponentInstantiation , ConfigurationInstantiation
7272from pyVHDLModel .DesignUnit import DesignUnit , PrimaryUnit , Architecture , PackageBody , Context , Entity , Configuration , Package
7373from pyVHDLModel .PSLModel import VerificationUnit , VerificationProperty , VerificationMode
@@ -854,28 +854,28 @@ def LinkContexts(self) -> None:
854854 for context in self .IterateDesignUnits (DesignUnitKind .Context ): # type: Context
855855 # Create entries in _referenced*** for the current working library under its real name.
856856 workingLibrary : Library = context .Library
857- libraryIdentifier = workingLibrary .NormalizedIdentifier
857+ libraryNormalizedIdentifier = workingLibrary ._normalizedIdentifier
858858
859- context ._referencedLibraries [libraryIdentifier ] = self ._libraries [libraryIdentifier ]
860- context ._referencedPackages [libraryIdentifier ] = {}
861- context ._referencedContexts [libraryIdentifier ] = {}
859+ context ._referencedLibraries [libraryNormalizedIdentifier ] = self ._libraries [libraryNormalizedIdentifier ]
860+ context ._referencedPackages [libraryNormalizedIdentifier ] = {}
861+ context ._referencedContexts [libraryNormalizedIdentifier ] = {}
862862
863863 # Process all library clauses
864864 for libraryReference in context ._libraryReferences :
865865 # A library clause can have multiple comma-separated references
866- for librarySymbol in libraryReference .Symbols :
867- libraryIdentifier = librarySymbol .Name .NormalizedIdentifier
866+ for libraryName in libraryReference .Symbols :
867+ libraryNormalizedIdentifier = libraryName .Name ._normalizedIdentifier
868868 try :
869- library = self ._libraries [libraryIdentifier ]
869+ library = self ._libraries [libraryNormalizedIdentifier ]
870870 except KeyError :
871- raise ReferencedLibraryNotExistingError (context , librarySymbol )
871+ raise ReferencedLibraryNotExistingError (context , libraryName )
872872 # TODO: add position to these messages
873873
874- librarySymbol .Library = library
874+ libraryName .Library = library
875875
876- context ._referencedLibraries [libraryIdentifier ] = library
877- context ._referencedPackages [libraryIdentifier ] = {}
878- context ._referencedContexts [libraryIdentifier ] = {}
876+ context ._referencedLibraries [libraryNormalizedIdentifier ] = library
877+ context ._referencedPackages [libraryNormalizedIdentifier ] = {}
878+ context ._referencedContexts [libraryNormalizedIdentifier ] = {}
879879 # TODO: warn duplicate library reference
880880
881881 dependency = context ._dependencyVertex .EdgeToVertex (library ._dependencyVertex , edgeValue = libraryReference )
@@ -884,33 +884,33 @@ def LinkContexts(self) -> None:
884884 # Process all use clauses
885885 for packageReference in context .PackageReferences :
886886 # A use clause can have multiple comma-separated references
887- for symbol in packageReference .Symbols :
888- packageSymbol = symbol .Name .Prefix
889- librarySymbol = packageSymbol .Prefix
887+ for symbol in packageReference .Symbols : # type: PackageReferenceSymbol
888+ packageName = symbol .Name .Prefix
889+ libraryName = packageName .Prefix
890890
891- libraryIdentifier = librarySymbol . NormalizedIdentifier
892- packageIdentifier = packageSymbol . NormalizedIdentifier
891+ libraryNormalizedIdentifier = libraryName . _normalizedIdentifier
892+ packageNormalizedIdentifier = packageName . _normalizedIdentifier
893893
894894 # In case work is used, resolve to the real library name.
895- if libraryIdentifier == "work" :
896- library : Library = context .Library
897- libraryIdentifier = library .NormalizedIdentifier
898- elif libraryIdentifier not in context ._referencedLibraries :
895+ if libraryNormalizedIdentifier == "work" :
896+ library : Library = context ._library
897+ libraryNormalizedIdentifier = library ._normalizedIdentifier
898+ elif libraryNormalizedIdentifier not in context ._referencedLibraries :
899899 # TODO: This check doesn't trigger if it's the working library.
900- raise VHDLModelException (f"Use clause references library '{ librarySymbol . Name . Identifier } ', which was not referenced by a library clause." )
900+ raise VHDLModelException (f"Use clause references library '{ libraryName . _identifier } ', which was not referenced by a library clause." )
901901 else :
902- library = self ._libraries [libraryIdentifier ]
902+ library = self ._libraries [libraryNormalizedIdentifier ]
903903
904904 try :
905- package = library ._packages [packageIdentifier ]
905+ package = library ._packages [packageNormalizedIdentifier ]
906906 except KeyError :
907- raise VHDLModelException (f"Package '{ packageSymbol . Name . Identifier } ' not found in { 'working ' if librarySymbol . NormalizedIdentifier == 'work' else '' } library '{ library .Identifier } '." )
907+ raise VHDLModelException (f"Package '{ packageName . _identifier } ' not found in { 'working ' if libraryName . _normalizedIdentifier == 'work' else '' } library '{ library ._identifier } '." )
908908
909- librarySymbol . Library = library
910- packageSymbol . Package = package
909+ symbol . Package = package
910+ assert package . Library == library
911911
912912 # TODO: warn duplicate package reference
913- context ._referencedPackages [libraryIdentifier ][ packageIdentifier ] = package
913+ context ._referencedPackages [libraryNormalizedIdentifier ][ packageNormalizedIdentifier ] = package
914914
915915 dependency = context ._dependencyVertex .EdgeToVertex (package ._dependencyVertex , edgeValue = packageReference )
916916 dependency ["kind" ] = DependencyGraphEdgeKind .UseClause
0 commit comments