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: String

Implementations§

§

impl Driver

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>

Runs the compiler pipeline and returns the appropriate file depending on the given options.

pub fn make_node_id(&mut self) -> AstNodeId

Creates a new AstNodeId.

pub fn options(&self) -> &DriverOptions

The compiler driver’s options.

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

Is the given flag set in the options?

pub fn set_flag(&mut self, flag: &str)

Turns a flag on.

pub fn diagnostics_enabled(&self) -> bool

Are diagnostics enabled?

pub fn set_diagnostics_enabled(&mut self, enabled: bool)

Sets whether diagnostics are enabled.

pub fn add_diagnostic(&mut self, diagnostic: Diagnostic)

Adds a diagnostic (error or warning).

pub fn has_error_diagnostics(&self) -> bool

Are there any error diagnostics?

pub fn error_count(&self) -> usize

The number of error diagnostics.

pub fn warning_count(&self) -> usize

The number of warning diagnostics.

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)

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)

For tests and debugging purposes, prints the diagnostics using the Debug trait.

Auto Trait Implementations§

§

impl Freeze for Driver

§

impl RefUnwindSafe for Driver

§

impl Send for Driver

§

impl Sync for Driver

§

impl Unpin for Driver

§

impl UnwindSafe for Driver

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.