Put default implementations of FuncWriter methods in a seperate method
This is useful when you want to write extra information
This commit is contained in:
@@ -41,6 +41,16 @@ pub trait FuncWriter {
|
||||
w: &mut Write,
|
||||
func: &Function,
|
||||
regs: Option<&RegInfo>,
|
||||
) -> Result<bool, fmt::Error> {
|
||||
self.super_preamble(w, func, regs)
|
||||
}
|
||||
|
||||
/// Default impl of `write_preamble`
|
||||
fn super_preamble(
|
||||
&mut self,
|
||||
w: &mut Write,
|
||||
func: &Function,
|
||||
regs: Option<&RegInfo>,
|
||||
) -> Result<bool, fmt::Error> {
|
||||
let mut any = false;
|
||||
|
||||
@@ -91,13 +101,24 @@ pub trait FuncWriter {
|
||||
}
|
||||
|
||||
/// Write an entity definition defined in the preamble to `w`.
|
||||
#[allow(unused_variables)]
|
||||
fn write_entity_definition(
|
||||
&mut self,
|
||||
w: &mut Write,
|
||||
func: &Function,
|
||||
entity: AnyEntity,
|
||||
value: &fmt::Display,
|
||||
) -> fmt::Result {
|
||||
self.super_entity_definition(w, func, entity, value)
|
||||
}
|
||||
|
||||
/// Default impl of `write_entity_definition`
|
||||
#[allow(unused_variables)]
|
||||
fn super_entity_definition(
|
||||
&mut self,
|
||||
w: &mut Write,
|
||||
func: &Function,
|
||||
entity: AnyEntity,
|
||||
value: &fmt::Display,
|
||||
) -> fmt::Result {
|
||||
writeln!(w, " {} = {}", entity, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user