pub struct FunctionTarget<'env> {
    pub func_env: &'env FunctionEnv<'env>,
    pub data: &'env FunctionData,
    /* private fields */
}
Expand description

A FunctionTarget is a drop-in replacement for a FunctionEnv which allows to rewrite and analyze bytecode and parameter/local types. It encapsulates a FunctionEnv and information which can be rewritten using the FunctionTargetsHolder data structure.

Fields§

§func_env: &'env FunctionEnv<'env>§data: &'env FunctionData

Implementations§

source§

impl<'env> FunctionTarget<'env>

source

pub fn new( func_env: &'env FunctionEnv<'env>, data: &'env FunctionData ) -> FunctionTarget<'env>

source

pub fn get_name(&self) -> Symbol

Returns the name of this function.

source

pub fn get_id(&self) -> FunId

Gets the id of this function.

source

pub fn symbol_pool(&self) -> &SymbolPool

Shortcut for accessing the symbol pool.

source

pub fn module_env(&self) -> &ModuleEnv<'_>

Shortcut for accessing the module env of this function.

source

pub fn global_env(&self) -> &GlobalEnv

Shortcut for accessing the global env of this function.

source

pub fn get_loc(&self) -> Loc

Returns the location of this function.

source

pub fn get_bytecode_loc(&self, attr_id: AttrId) -> Loc

Returns the location of the bytecode with the given attribute.

source

pub fn get_debug_comment(&self, attr_id: AttrId) -> Option<&String>

Returns the debug comment, if any, associated with the given attribute.

source

pub fn get_vc_info(&self, attr_id: AttrId) -> Option<&String>

Returns the verification condition message, if any, associated with the given attribute.

source

pub fn is_native(&self) -> bool

Returns true if this function is native.

source

pub fn is_intrinsic(&self) -> bool

Returns true if this function is marked as intrinsic

source

pub fn is_opaque(&self) -> bool

Returns true if this function is opaque.

source

pub fn is_exposed(&self) -> bool

Returns true if this function has public, friend, or script visibility.

source

pub fn visibility(&self) -> FunctionVisibility

Returns the visibility of this function.

source

pub fn is_mutating(&self) -> bool

Returns true if this function mutates any references (i.e. has &mut parameters).

source

pub fn get_type_parameters(&self) -> Vec<TypeParameter>

Returns the type parameters associated with this function.

source

pub fn get_return_type(&self, idx: usize) -> &Type

Returns return type at given index.

source

pub fn get_return_types(&self) -> &[Type]

Returns return types of this function.

source

pub fn get_return_count(&self) -> usize

Returns the number of return values of this function.

source

pub fn get_parameter_count(&self) -> usize

Return the number of parameters of this function

source

pub fn get_parameters(&self) -> Range<usize>

Return an iterator over this function’s parameters

source

pub fn get_local_name(&self, idx: usize) -> Symbol

Get the name to be used for a local. If the local has a user name, use that for naming, otherwise generate a unique name.

source

pub fn has_local_user_name(&self, idx: usize) -> bool

Return true if this local has a user name.

source

pub fn get_local_index(&self, name: Symbol) -> Option<usize>

Get the index corresponding to a local name. The name must either match a user name, or have the syntax $t<N>$.

source

pub fn get_local_count(&self) -> usize

Gets the number of locals of this function, including parameters.

source

pub fn get_user_local_count(&self) -> usize

Gets the number of user declared locals of this function, excluding locals which have been introduced by transformations.

source

pub fn get_non_parameter_locals(&self) -> Range<usize>

Return an iterator over the non-parameter local variables of this function

source

pub fn is_temporary(&self, idx: usize) -> bool

Returns true if the index is for a temporary, not user declared local.

source

pub fn get_local_type(&self, idx: usize) -> &Type

Gets the type of the local at index. This must use an index in the range as determined by get_local_count.

source

pub fn get_spec(&'env self) -> &'env Spec

Returns specification associated with this function.

source

pub fn is_pragma_true(&self, name: &str, default: impl FnOnce() -> bool) -> bool

Returns the value of a boolean pragma for this function. This first looks up a pragma in this function, then the enclosing module, and finally uses the provided default. property

source

pub fn get_bytecode(&self) -> &[Bytecode]

Gets the bytecode.

source

pub fn get_annotations(&self) -> &'env Annotations

Gets annotations.

source

pub fn get_acquires_global_resources(&self) -> &[StructId]

Gets acquired resources

source

pub fn get_mut_ref_return_index(&self, idx: usize) -> Option<usize>

Gets index of return parameter for a reference input parameter, or None, if this is not a reference parameter.

source

pub fn get_mut_ref_mapping(&self) -> BTreeMap<TempIndex, usize>

Returns a map from &mut parameters to the return indices associated with them after &mut instrumentation. By convention, the return values are appended after the regular function parameters, in the order they are in the parameter list.

source

pub fn get_modify_targets_for_type( &self, ty: &QualifiedId<StructId> ) -> Option<&Vec<Exp>>

Gets modify targets for a type

source

pub fn get_modify_targets(&self) -> &BTreeMap<QualifiedId<StructId>, Vec<Exp>>

Gets all modify targets

source

pub fn get_modify_ids(&self) -> BTreeSet<QualifiedInstId<StructId>>

Get all modifies targets, as instantiated struct ids.

source

pub fn get_modify_ids_and_exps( &self ) -> BTreeMap<QualifiedInstId<StructId>, Vec<&Exp>>

source

pub fn pretty_print_bytecode( &self, label_offsets: &BTreeMap<Label, CodeOffset>, offset: usize, code: &Bytecode ) -> String

Pretty print a bytecode instruction with offset, comments, annotations, and VC information.

source§

impl<'env> FunctionTarget<'env>

source

pub fn register_annotation_formatter(&self, formatter: Box<AnnotationFormatter>)

Register a formatter. Each function target processor which introduces new annotations should register a formatter in order to get is value printed when a function target is displayed for debugging or testing.

source

pub fn register_annotation_formatters_for_test(&self)

Tests use this function to register all relevant annotation formatters. Extend this with new formatters relevant for tests.

Trait Implementations§

source§

impl<'env> Clone for FunctionTarget<'env>

source§

fn clone(&self) -> Self

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<'env> Display for FunctionTarget<'env>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'env> !RefUnwindSafe for FunctionTarget<'env>

§

impl<'env> !Send for FunctionTarget<'env>

§

impl<'env> !Sync for FunctionTarget<'env>

§

impl<'env> Unpin for FunctionTarget<'env>

§

impl<'env> !UnwindSafe for FunctionTarget<'env>

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, 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