finish DefaultMutationalStage
This commit is contained in:
parent
2e711360c1
commit
b2a6ddb0dd
@ -5,6 +5,9 @@ use crate::inputs::Input;
|
|||||||
use crate::engines::Engine;
|
use crate::engines::Engine;
|
||||||
use crate::AflError;
|
use crate::AflError;
|
||||||
|
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub trait HasEngine<'a, I> where I: Input {
|
pub trait HasEngine<'a, I> where I: Input {
|
||||||
type E : Engine<'a, I>;
|
type E : Engine<'a, I>;
|
||||||
|
|
||||||
@ -15,5 +18,5 @@ pub trait HasEngine<'a, I> where I: Input {
|
|||||||
|
|
||||||
pub trait Stage<'a, I> : HasEngine<'a, I> where I: Input {
|
pub trait Stage<'a, I> : HasEngine<'a, I> where I: Input {
|
||||||
/// Run the stage
|
/// Run the stage
|
||||||
fn perform(&mut self, entry: &mut Testcase<I>) -> Result<(), AflError>;
|
fn perform(&mut self, entry: Rc<RefCell<Testcase<I>>>) -> Result<(), AflError>;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ use crate::engines::Engine;
|
|||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
// TODO create HasMutatorsVec trait
|
||||||
|
|
||||||
pub trait MutationalStage<'a, I> : Stage<'a, I> + HasRand where I: Input {
|
pub trait MutationalStage<'a, I> : Stage<'a, I> + HasRand where I: Input {
|
||||||
fn mutators(&self) -> &Vec<Box<dyn Mutator<I, R = Self::R>>>;
|
fn mutators(&self) -> &Vec<Box<dyn Mutator<I, R = Self::R>>>;
|
||||||
|
|
||||||
@ -71,4 +73,30 @@ impl<'a, I, R, E> HasEngine<'a, I> for DefaultMutationalStage<'a, I, R, E> where
|
|||||||
fn engine_mut(&mut self) -> &mut Self::E {
|
fn engine_mut(&mut self) -> &mut Self::E {
|
||||||
self.engine
|
self.engine
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, I, R, E> MutationalStage<'a, I> for DefaultMutationalStage<'a, I, R, E> where I: Input, R: Rand, E: Engine<'a, I> {
|
||||||
|
fn mutators(&self) -> &Vec<Box<dyn Mutator<I, R = Self::R>>> {
|
||||||
|
&self.mutators
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mutators_mut(&mut self) -> &mut Vec<Box<dyn Mutator<I, R = Self::R>>> {
|
||||||
|
&mut self.mutators
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, I, R, E> Stage<'a, I> for DefaultMutationalStage<'a, I, R, E> where I: Input, R: Rand, E: Engine<'a, I> {
|
||||||
|
fn perform(&mut self, entry: Rc<RefCell<Testcase<I>>>) -> Result<(), AflError> {
|
||||||
|
self.perform_mutational(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, I, R, E> DefaultMutationalStage<'a, I, R, E> where I: Input, R: Rand, E: Engine<'a, I> {
|
||||||
|
pub fn new(rand: &'a mut R, engine: &'a mut E) -> Self {
|
||||||
|
DefaultMutationalStage {
|
||||||
|
rand: rand,
|
||||||
|
engine: engine,
|
||||||
|
mutators: vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user