pub trait Backend {
type Printer: Printer;
const NAME: &'static str = <Self::Printer>::NAME;
// Required method
fn module_path(&self, module: &Module) -> Utf8PathBuf;
// Provided methods
fn printer(&self, linked_item_graph: Rc<LinkedItemGraph>) -> Self::Printer { ... }
fn phases(&self) -> Vec<PhaseKind> { ... }
fn resugaring_phases() -> Vec<Box<dyn Resugaring>> { ... }
fn items_to_module(&self, items: Vec<Item>) -> Vec<Module> { ... }
fn modules_to_files(
&self,
modules: Vec<Module>,
printer: Self::Printer,
) -> Vec<File> { ... }
}Expand description
A hax backend.
A backend is responsible for turning the hax AST into sources of a target language. It combines:
- a sequence of AST transformation phases, and
- a printer that generates textual output.
For example, we have F*, Coq, and Lean backends. Some are still in the old OCaml engine.
Provided Associated Constants§
Sourceconst NAME: &'static str = <Self::Printer>::NAME
const NAME: &'static str = <Self::Printer>::NAME
A short name identifying the backend.
By default, this is delegated to the associated printer’s Printer::NAME.
Required Associated Types§
Required Methods§
Sourcefn module_path(&self, module: &Module) -> Utf8PathBuf
fn module_path(&self, module: &Module) -> Utf8PathBuf
Compute the relative filesystem path where a given module should be written.
Provided Methods§
Sourcefn printer(&self, linked_item_graph: Rc<LinkedItemGraph>) -> Self::Printer
fn printer(&self, linked_item_graph: Rc<LinkedItemGraph>) -> Self::Printer
Construct a new printer instance.
By default this calls Default::default on the printer type.
Sourcefn phases(&self) -> Vec<PhaseKind>
fn phases(&self) -> Vec<PhaseKind>
The AST phases to apply before printing.
Backends can override this to add transformations. The default is an empty list (no transformations).
Sourcefn resugaring_phases() -> Vec<Box<dyn Resugaring>>
fn resugaring_phases() -> Vec<Box<dyn Resugaring>>
A list of resugaring phases.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".