class
#include <slang/driver/SourceLoader.h>
SourceLoader Handles loading and parsing of groups of source files.
This class handles high-level descriptions of how to load and parse source files, such as via library mapping files or search directories to look in. The actual loading and parsing are delegated to classes like SourceManager and SyntaxTree.
Constructors, destructors, conversion operators
- SourceLoader(SourceManager& sourceManager) explicit
- Constructs a new instance of the SourceLoader class.
Public functions
-
void addFiles(std::
string_view pattern) - Adds files to be loaded, specified via the given pattern.
-
void addLibraryFiles(std::
string_view libraryName, std:: string_view pattern) - Adds library files to be loaded, specified via the given pattern.
-
void addSearchDirectories(std::
string_view pattern) - Adds directories in which to search for library module files, specified via the given pattern.
-
void addSearchExtension(std::
string_view extension) - Adds an extension used to search for library module files.
-
void addLibraryMaps(std::
string_view pattern, const std:: filesystem:: path& basePath, const Bag& optionBag) - Adds library map files to the loader.
- auto getLibraryMaps() const -> const SyntaxTreeList&
- Returns a list of all library map syntax trees that have been loaded and parsed.
- auto hasFiles() const -> bool
- Returns true if there is at least one source file to load, and false if none have been added to the loader.
-
auto loadSources() -> std::
vector<SourceBuffer> - Loads all of the sources that have been added to the loader, but does not parse them.
- auto loadAndParseSources(const Bag& optionBag) -> SyntaxTreeList
- Loads and parses all of the source files that have been added to the loader.
-
auto getErrors() const -> std::
span<const std:: string> - Gets the list of errors that have occurred while loading files.
Function documentation
void slang:: driver:: SourceLoader:: addFiles(std:: string_view pattern)
Adds files to be loaded, specified via the given pattern.
All of the files that match the pattern will be added for loading. If no files match and the pattern is actually just a specific filename an error will be issued.
void slang:: driver:: SourceLoader:: addLibraryFiles(std:: string_view libraryName,
std:: string_view pattern)
Adds library files to be loaded, specified via the given pattern.
All of the files that match the pattern will be added for loading. If no files match and the pattern is actually just a specific filename an error will be issued.
Library files differ from regular source files in that they are only considered "used" if referenced in the main source and their modules are not automatically instantiated.
void slang:: driver:: SourceLoader:: addSearchDirectories(std:: string_view pattern)
Adds directories in which to search for library module files, specified via the given pattern.
A search for a library module occurs when there are instantiations found for unknown modules (or interfaces or programs). The given directories will be searched for files with the missing module's name plus any registered search extensions.
void slang:: driver:: SourceLoader:: addSearchExtension(std:: string_view extension)
Adds an extension used to search for library module files.
A search for a library module occurs when there are instantiations found for unknown modules (or interfaces or programs). The search will be for files with the given extensions.
Note that the extensions ".v" and ".sv" are always automatically included in the search set.
void slang:: driver:: SourceLoader:: addLibraryMaps(std:: string_view pattern,
const std:: filesystem:: path& basePath,
const Bag& optionBag)
Adds library map files to the loader.
All files that match the given pattern will be loaded and parsed as if they were library map files. The libraries within those maps will be created and any files they reference will be included in the list to load.
std:: vector<SourceBuffer> slang:: driver:: SourceLoader:: loadSources()
Loads all of the sources that have been added to the loader, but does not parse them.
Returns the loaded buffers.