class
#include <slang/driver/Driver.h>
Driver A top-level class that handles argument parsing, option preparation, and invoking various parts of the slang compilation process. This is exposed as a convenience wrapper around the various components that could otherwise be used on their own.
Public types
- struct Options
Constructors, destructors, conversion operators
- Driver()
- Constructs a new instance of the Driver class.
Public functions
- void addStandardArgs()
-
template<typename TArgs>auto parseCommandLine(int argc, TArgs argv) -> bool
- auto parseCommandLine(std::string_view argList) -> bool
- auto readSource(std::string_view fileName) -> SourceBuffer
- auto processCommandFile(std::string_view fileName, bool makeRelative) -> bool
- auto processOptions() -> bool
- auto runPreprocessor(bool includeComments, bool includeDirectives, bool obfuscateIds, bool useFixedObfuscationSeed = false) -> bool
- void reportMacros()
- Prints all macros from all loaded buffers to stdout.
- auto parseAllSources() -> bool
- auto createOptionBag() const -> Bag
- Creates an options bag from all of the currently set options.
-
auto createCompilation() const -> std::unique_ptr<ast::
Compilation> - Creates a compilation object from all of the current loaded state of the driver.
- auto reportParseDiags() -> bool
-
auto reportCompilation(ast::
Compilation& compilation, bool quiet) -> bool
Public variables
- CommandLine cmdLine
- SourceManager sourceManager
- The source manager that holds all loaded source files.
- DiagnosticEngine diagEngine
- The diagnostics engine that will be used to report diagnostics.
- std::shared_ptr<TextDiagnosticClient> diagClient
- The diagnostics client that will be used to render diagnostics.
- std::vector<SourceBuffer> buffers
- A list of source buffers that have been loaded.
-
std::vector<std::shared_ptr<syntax::
SyntaxTree>> syntaxTrees - A list of syntax trees that have been parsed.
Function documentation
void slang:: driver:: Driver:: addStandardArgs()
Adds standard command line arguments to the cmdLine object. If not called, no arguments will be added by default, though the user can still add their own custom arguments if desired.
template<typename TArgs>
bool slang:: driver:: Driver:: parseCommandLine(int argc,
TArgs argv)
Parses command line arguments from the given C-style argument list. This is templated to support both char and wchar_t arg lists. Any errors encountered will be printed to stderr.
bool slang:: driver:: Driver:: parseCommandLine(std::string_view argList)
Parses command line arguments from the given string. Any errors encountered will be printed to stderr.
SourceBuffer slang:: driver:: Driver:: readSource(std::string_view fileName)
Reads a source file into the SourceManager and returns the buffer handle for it. If an error occurs a diagnostic will be issued to stderr.
bool slang:: driver:: Driver:: processCommandFile(std::string_view fileName,
bool makeRelative)
Parameters | |
---|---|
fileName | The name (and potentially the path) of the command file to process. |
makeRelative | indicates whether paths in the file are relative to the file itself or to the current working directory. |
Returns | true on success and false if errors were encountered. |
Processes the given command file for more options. Any errors encountered will be printed to stderr.
bool slang:: driver:: Driver:: processOptions()
Returns | true on success and false if errors were encountered. |
---|
Processes and applies all configured options.
bool slang:: driver:: Driver:: runPreprocessor(bool includeComments,
bool includeDirectives,
bool obfuscateIds,
bool useFixedObfuscationSeed = false)
Parameters | |
---|---|
includeComments | If true, comments will be included in the output. |
includeDirectives | If true, preprocessor directives will be included in the output. |
obfuscateIds | If true, identifiers will be obfuscated by replacing them with randomized alphanumeric strings. |
useFixedObfuscationSeed | If true, obfuscated identifiers will be generated with a fixed randomization seed, meaning they will be the same every time the program is run. Used for testing. |
Returns | true on success and false if errors were encountered. |
Runs the preprocessor on all loaded buffers and outputs the result to stdout. Any errors encountered will be printed to stderr.
bool slang:: driver:: Driver:: parseAllSources()
Returns | true on success and false if errors were encountered. |
---|
Parses all loaded buffers into syntax trees and appends the resulting trees to the syntaxTrees list.
bool slang:: driver:: Driver:: reportParseDiags()
Returns | true on success and false if errors were encountered. |
---|
Reports all parsing diagnostics found in all of the syntaxTrees
bool slang:: driver:: Driver:: reportCompilation(ast:: Compilation& compilation,
bool quiet)
Returns | true if compilation succeeded and false if errors were encountered. |
---|
Reports the result of compilation. If quiet is set to true, non-essential output will be suppressed.
Variable documentation
CommandLine slang:: driver:: Driver:: cmdLine
The command line object that will be used to parse arguments if the parseCommandLine method is called.