use ryo_source::pure::PureExpr;
use ryo_symbol::SymbolId;
use crate::Mutation;
#[derive(Debug, Clone)]
pub struct ReplaceExprAtMutation {
pub target_fn: SymbolId,
pub body_indices: Vec<usize>,
pub new_expr: PureExpr,
}
impl ReplaceExprAtMutation {
pub fn new(target_fn: SymbolId, body_indices: Vec<usize>, new_expr: PureExpr) -> Self {
Self {
target_fn,
body_indices,
new_expr,
}
}
}
impl Mutation for ReplaceExprAtMutation {
fn describe(&self) -> String {
format!(
"Replace expression at {}::$body::{}",
self.target_fn,
self.body_indices
.iter()
.map(|i| i.to_string())
.collect::<Vec<_>>()
.join("::")
)
}
fn mutation_type(&self) -> &'static str {
"ReplaceExprAt"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}