1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! A successor after concrete evaluation of a Falcon IL Instruction.

use executor::State;
use il;


/// A representation of the successor location in an `il::Program` after
/// execution of an `il::Operation`.
#[derive(Clone, Debug)]
pub enum SuccessorType {
    FallThrough,
    Branch(u64),
    Intrinsic(il::Intrinsic)
}


/// The result of executing an `il::Operation` over a `State`.
#[derive(Clone)]
pub struct Successor {
    state: State,
    type_: SuccessorType
}


impl Successor {
    pub(crate) fn new(state: State, type_: SuccessorType) -> Successor {
        Successor {
            state: state,
            type_: type_
        }
    }

    /// Get the `SuccessorType` of this `Successor`.
    pub fn type_(&self) -> &SuccessorType {
        &self.type_
    }


    /// Get the `State` of this `Successor`.
    pub fn state(&self) -> &State {
        &self.state
    }
}


/// Turn this `Successor` into its `State`, discarding the `SuccessorType`.
impl Into<State> for Successor {
    fn into(self) -> State {
        self.state
    }
}