Struct test_generation::abstract_state::AbstractState
source · pub struct AbstractState {
pub instantiation: Vec<AbilitySet>,
pub module: InstantiableModule,
pub acquires_global_resources: Vec<StructDefinitionIndex>,
pub call_graph: CallGraph,
/* private fields */
}
Expand description
An AbstractState represents an abstract view of the execution of the
Move VM. Rather than considering values of items on the stack or in
the locals, we only consider their type, represented by a AbstractValue
and their availibility, represented by the BorrowState
.
Fields§
§instantiation: Vec<AbilitySet>
A vector of type kinds for any generic function type parameters of the function that we are in.
module: InstantiableModule
The module state
acquires_global_resources: Vec<StructDefinitionIndex>
The global resources acquired by the function corresponding to this abstract state
call_graph: CallGraph
Implementations§
source§impl AbstractState
impl AbstractState
sourcepub fn new() -> AbstractState
pub fn new() -> AbstractState
Create a new AbstractState with empty stack, locals, and register
sourcepub fn from_locals(
module: CompiledModule,
locals: HashMap<usize, (AbstractValue, BorrowState)>,
instantiation: Vec<AbilitySet>,
acquires_global_resources: Vec<StructDefinitionIndex>,
call_graph: CallGraph
) -> AbstractState
pub fn from_locals( module: CompiledModule, locals: HashMap<usize, (AbstractValue, BorrowState)>, instantiation: Vec<AbilitySet>, acquires_global_resources: Vec<StructDefinitionIndex>, call_graph: CallGraph ) -> AbstractState
Create a new AbstractState given a list of SignatureTokens
that will be
the (available) locals that the state will have, as well as the module state
sourcepub fn register_copy(&self) -> Option<AbstractValue>
pub fn register_copy(&self) -> Option<AbstractValue>
Get the register value
sourcepub fn register_move(&mut self) -> Option<AbstractValue>
pub fn register_move(&mut self) -> Option<AbstractValue>
Get the register value and set it to None
sourcepub fn register_set(&mut self, value: AbstractValue)
pub fn register_set(&mut self, value: AbstractValue)
Set the register value and set it to None
sourcepub fn stack_push(&mut self, item: AbstractValue)
pub fn stack_push(&mut self, item: AbstractValue)
Add a AbstractValue
to the stack
sourcepub fn stack_push_register(&mut self) -> Result<(), VMError>
pub fn stack_push_register(&mut self) -> Result<(), VMError>
Add a AbstractValue
to the stack from the register
If the register is None
return a VMError
sourcepub fn stack_pop(&mut self) -> Result<(), VMError>
pub fn stack_pop(&mut self) -> Result<(), VMError>
Remove an AbstractValue
from the stack if it exists to the register
If it does not exist return a VMError
.
sourcepub fn stack_peek(&self, index: usize) -> Option<AbstractValue>
pub fn stack_peek(&self, index: usize) -> Option<AbstractValue>
Get the AbstractValue
at index index
on the stack if it exists.
Index 0 is the top of the stack.
sourcepub fn local_exists(&self, i: usize) -> bool
pub fn local_exists(&self, i: usize) -> bool
Check if the local at index i
exists
sourcepub fn local_get(&self, i: usize) -> Option<&(AbstractValue, BorrowState)>
pub fn local_get(&self, i: usize) -> Option<&(AbstractValue, BorrowState)>
Get the local at index i
if it exists
sourcepub fn local_take(&mut self, i: usize) -> Result<(), VMError>
pub fn local_take(&mut self, i: usize) -> Result<(), VMError>
Place the local at index i
if it exists into the register
If it does not exist return a VMError
.
sourcepub fn local_take_borrow(
&mut self,
i: usize,
mutability: Mutability
) -> Result<(), VMError>
pub fn local_take_borrow( &mut self, i: usize, mutability: Mutability ) -> Result<(), VMError>
Place a reference to the local at index i
if it exists into the register
If it does not exist return a VMError
.
sourcepub fn local_set(
&mut self,
i: usize,
availability: BorrowState
) -> Result<(), VMError>
pub fn local_set( &mut self, i: usize, availability: BorrowState ) -> Result<(), VMError>
Set the availability of the local at index i
If it does not exist return a VMError
.
sourcepub fn local_availability_is(
&self,
i: usize,
availability: BorrowState
) -> Result<bool, VMError>
pub fn local_availability_is( &self, i: usize, availability: BorrowState ) -> Result<bool, VMError>
Check whether a local is in a particular BorrowState
If the local does not exist return a VMError
.
sourcepub fn local_has_ability(
&self,
i: usize,
ability: Ability
) -> Result<bool, VMError>
pub fn local_has_ability( &self, i: usize, ability: Ability ) -> Result<bool, VMError>
Check whether a local has a particular Ability
If the local does not exist return a VMError
.
sourcepub fn local_insert(
&mut self,
i: usize,
abstract_value: AbstractValue,
availability: BorrowState
)
pub fn local_insert( &mut self, i: usize, abstract_value: AbstractValue, availability: BorrowState )
Insert a local at index i
as Available
sourcepub fn local_place(&mut self, i: usize) -> Result<(), VMError>
pub fn local_place(&mut self, i: usize) -> Result<(), VMError>
Insert a local at index i
as Available
from the register
If the register value is None
return a VMError
.
sourcepub fn get_locals(&self) -> &HashMap<usize, (AbstractValue, BorrowState)>
pub fn get_locals(&self) -> &HashMap<usize, (AbstractValue, BorrowState)>
Get all of the locals
sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Set the abstract state to be aborted
when a precondition of an instruction
fails. (This will happen if NEGATE_PRECONDITIONs
is true).
sourcepub fn has_aborted(&self) -> bool
pub fn has_aborted(&self) -> bool
Whether the state is aborted
sourcepub fn allow_control_flow(&mut self)
pub fn allow_control_flow(&mut self)
Set the abstract state to allow generation of control flow operations.
sourcepub fn is_control_flow_allowed(&self) -> bool
pub fn is_control_flow_allowed(&self) -> bool
Predicate determining if control flow instructions can be generated.
Trait Implementations§
source§impl Clone for AbstractState
impl Clone for AbstractState
source§fn clone(&self) -> AbstractState
fn clone(&self) -> AbstractState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more