Struct Driver
pub struct Driver {
pub source_file_path: String,
pub tu_file: TuFile,
pub asm_filename: String,
/* private fields */
}Expand description
The BlueC compiler driver.
The compiler driver orchestrates the compilation pipeline and, if necessary, invokes gcc to run the assembler
and/or linker after BlueC compiles the C source code. Modify the DriverOptions to control the driver’s behavior.
Driver is a compiler driver for a single C source file. To drive the compilation and linking of multiple source
files, use multi_file_driver::compile_and_link.
§Examples
let options = DriverOptions::default();
let mut driver = Driver::new("source_file.c", options);
_ = driver.run();
if driver.has_error_diagnostics() {
driver.print_diagnostics();
}Fields§
§source_file_path: String§tu_file: TuFile§asm_filename: StringImplementations§
§impl Driver
impl Driver
pub fn new(source_file_path: &str, options: DriverOptions) -> Self
pub fn new(source_file_path: &str, options: DriverOptions) -> Self
Creates a new compiler driver configured to compile the given source file.
pub fn run(&mut self) -> Result<CompilerGeneratedFile, DriverError>
pub fn run(&mut self) -> Result<CompilerGeneratedFile, DriverError>
Runs the compiler pipeline and returns the appropriate file depending on the given options.
pub fn make_node_id(&mut self) -> AstNodeId
pub fn make_node_id(&mut self) -> AstNodeId
Creates a new AstNodeId.
pub fn options(&self) -> &DriverOptions
pub fn options(&self) -> &DriverOptions
The compiler driver’s options.
pub fn take_options(&mut self) -> Option<DriverOptions>
pub fn take_options(&mut self) -> Option<DriverOptions>
Takes ownership of the compiler driver’s options.
pub fn is_flag_set(&self, flag: &str) -> bool
pub fn is_flag_set(&self, flag: &str) -> bool
Is the given flag set in the options?
pub fn diagnostics_enabled(&self) -> bool
pub fn diagnostics_enabled(&self) -> bool
Are diagnostics enabled?
pub fn set_diagnostics_enabled(&mut self, enabled: bool)
pub fn set_diagnostics_enabled(&mut self, enabled: bool)
Sets whether diagnostics are enabled.
pub fn add_diagnostic(&mut self, diagnostic: Diagnostic)
pub fn add_diagnostic(&mut self, diagnostic: Diagnostic)
Adds a diagnostic (error or warning).
pub fn has_error_diagnostics(&self) -> bool
pub fn has_error_diagnostics(&self) -> bool
Are there any error diagnostics?
pub fn error_count(&self) -> usize
pub fn error_count(&self) -> usize
The number of error diagnostics.
pub fn warning_count(&self) -> usize
pub fn warning_count(&self) -> usize
The number of warning diagnostics.
pub fn print_diagnostics(&mut self)
pub fn print_diagnostics(&mut self)
Prints all diagnostics to stderr, with any errors printed first before any warnings.
pub fn print_diagnostics_to_buffer(&mut self, buffer: impl Write)
pub fn print_diagnostics_to_buffer(&mut self, buffer: impl Write)
Prints all diagnostics to the given buffer, with any errors printed first before any warnings.
You probably want print_diagnostics instead of this function, unless you deliberately want to print
diagnostics into a buffer.
pub fn debug_print_diagnostics(&self)
pub fn debug_print_diagnostics(&self)
For tests and debugging purposes, prints the diagnostics using the Debug trait.