use ryo_source::pure::PureExpr;
use ryo_symbol::SymbolId;
use crate::Mutation;
#[derive(Debug, Clone)]
pub struct ReplaceExprMutation {
pub old_expr: PureExpr,
pub new_expr: PureExpr,
pub target_fn: SymbolId,
pub replace_all: bool,
}
impl ReplaceExprMutation {
pub fn new(old_expr: PureExpr, new_expr: PureExpr, target_fn: SymbolId) -> Self {
Self {
old_expr,
new_expr,
target_fn,
replace_all: true,
}
}
pub fn first_only(mut self) -> Self {
self.replace_all = false;
self
}
}
impl Mutation for ReplaceExprMutation {
fn describe(&self) -> String {
"Replace expression with another expression".to_string()
}
fn mutation_type(&self) -> &'static str {
"ReplaceExpr"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}