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

source

pub fn new() -> AbstractState

Create a new AbstractState with empty stack, locals, and register

source

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

source

pub fn register_copy(&self) -> Option<AbstractValue>

Get the register value

source

pub fn register_move(&mut self) -> Option<AbstractValue>

Get the register value and set it to None

source

pub fn register_set(&mut self, value: AbstractValue)

Set the register value and set it to None

source

pub fn stack_push(&mut self, item: AbstractValue)

Add a AbstractValue to the stack

source

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

source

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.

source

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.

source

pub fn stack_len(&self) -> usize

Get the length of the stack.

source

pub fn local_exists(&self, i: usize) -> bool

Check if the local at index i exists

source

pub fn local_get(&self, i: usize) -> Option<&(AbstractValue, BorrowState)>

Get the local at index i if it exists

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn local_insert( &mut self, i: usize, abstract_value: AbstractValue, availability: BorrowState )

Insert a local at index i as Available

source

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.

source

pub fn get_locals(&self) -> &HashMap<usize, (AbstractValue, BorrowState)>

Get all of the locals

source

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).

source

pub fn has_aborted(&self) -> bool

Whether the state is aborted

source

pub fn allow_control_flow(&mut self)

Set the abstract state to allow generation of control flow operations.

source

pub fn is_control_flow_allowed(&self) -> bool

Predicate determining if control flow instructions can be generated.

source

pub fn is_final(&self) -> bool

The final state is one where the stack is empty

Trait Implementations§

source§

impl Clone for AbstractState

source§

fn clone(&self) -> AbstractState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AbstractState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AbstractState

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for AbstractState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more