pub trait Backend {
// Required methods
fn name(&self) -> &'static str;
fn validate(prog: &Context) -> CalyxResult<()>;
fn emit(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>;
fn link_externs(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>;
// Provided method
fn run(&self, prog: Context, file: OutputFile) -> CalyxResult<()> { ... }
}
Expand description
A backend for Calyx.
Required Methods§
Sourcefn validate(prog: &Context) -> CalyxResult<()>
fn validate(prog: &Context) -> CalyxResult<()>
Validate this program for emitting using this backend. Returns an Err(..) if the program has unexpected constructs.
Sourcefn emit(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>
fn emit(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>
Transforms the program into a formatted string representing a valid
and write it to write
.
Sourcefn link_externs(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>
fn link_externs(prog: &Context, write: &mut OutputFile) -> CalyxResult<()>
Link the extern collected while parsing the program.
Provided Methods§
Sourcefn run(&self, prog: Context, file: OutputFile) -> CalyxResult<()>
fn run(&self, prog: Context, file: OutputFile) -> CalyxResult<()>
Convience function to validate and emit the program.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.