Struct bytecode::function_target::FunctionTarget
source · 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>
impl<'env> FunctionTarget<'env>
pub fn new( func_env: &'env FunctionEnv<'env>, data: &'env FunctionData ) -> FunctionTarget<'env>
sourcepub fn symbol_pool(&self) -> &SymbolPool
pub fn symbol_pool(&self) -> &SymbolPool
Shortcut for accessing the symbol pool.
sourcepub fn module_env(&self) -> &ModuleEnv<'_>
pub fn module_env(&self) -> &ModuleEnv<'_>
Shortcut for accessing the module env of this function.
sourcepub fn global_env(&self) -> &GlobalEnv
pub fn global_env(&self) -> &GlobalEnv
Shortcut for accessing the global env of this function.
sourcepub fn get_bytecode_loc(&self, attr_id: AttrId) -> Loc
pub fn get_bytecode_loc(&self, attr_id: AttrId) -> Loc
Returns the location of the bytecode with the given attribute.
sourcepub fn get_debug_comment(&self, attr_id: AttrId) -> Option<&String>
pub fn get_debug_comment(&self, attr_id: AttrId) -> Option<&String>
Returns the debug comment, if any, associated with the given attribute.
sourcepub fn get_vc_info(&self, attr_id: AttrId) -> Option<&String>
pub fn get_vc_info(&self, attr_id: AttrId) -> Option<&String>
Returns the verification condition message, if any, associated with the given attribute.
sourcepub fn is_intrinsic(&self) -> bool
pub fn is_intrinsic(&self) -> bool
Returns true if this function is marked as intrinsic
sourcepub fn is_exposed(&self) -> bool
pub fn is_exposed(&self) -> bool
Returns true if this function has public, friend, or script visibility.
sourcepub fn visibility(&self) -> FunctionVisibility
pub fn visibility(&self) -> FunctionVisibility
Returns the visibility of this function.
sourcepub fn is_mutating(&self) -> bool
pub fn is_mutating(&self) -> bool
Returns true if this function mutates any references (i.e. has &mut parameters).
sourcepub fn get_type_parameters(&self) -> Vec<TypeParameter> ⓘ
pub fn get_type_parameters(&self) -> Vec<TypeParameter> ⓘ
Returns the type parameters associated with this function.
sourcepub fn get_return_type(&self, idx: usize) -> &Type
pub fn get_return_type(&self, idx: usize) -> &Type
Returns return type at given index.
sourcepub fn get_return_types(&self) -> &[Type]
pub fn get_return_types(&self) -> &[Type]
Returns return types of this function.
sourcepub fn get_return_count(&self) -> usize
pub fn get_return_count(&self) -> usize
Returns the number of return values of this function.
sourcepub fn get_parameter_count(&self) -> usize
pub fn get_parameter_count(&self) -> usize
Return the number of parameters of this function
sourcepub fn get_parameters(&self) -> Range<usize>
pub fn get_parameters(&self) -> Range<usize>
Return an iterator over this function’s parameters
sourcepub fn get_local_name(&self, idx: usize) -> Symbol
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.
sourcepub fn has_local_user_name(&self, idx: usize) -> bool
pub fn has_local_user_name(&self, idx: usize) -> bool
Return true if this local has a user name.
sourcepub fn get_local_index(&self, name: Symbol) -> Option<usize>
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>$
.
sourcepub fn get_local_count(&self) -> usize
pub fn get_local_count(&self) -> usize
Gets the number of locals of this function, including parameters.
sourcepub fn get_user_local_count(&self) -> usize
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.
sourcepub fn get_non_parameter_locals(&self) -> Range<usize>
pub fn get_non_parameter_locals(&self) -> Range<usize>
Return an iterator over the non-parameter local variables of this function
sourcepub fn is_temporary(&self, idx: usize) -> bool
pub fn is_temporary(&self, idx: usize) -> bool
Returns true if the index is for a temporary, not user declared local.
sourcepub fn get_local_type(&self, idx: usize) -> &Type
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
.
sourcepub fn is_pragma_true(&self, name: &str, default: impl FnOnce() -> bool) -> bool
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
sourcepub fn get_bytecode(&self) -> &[Bytecode]
pub fn get_bytecode(&self) -> &[Bytecode]
Gets the bytecode.
sourcepub fn get_annotations(&self) -> &'env Annotations
pub fn get_annotations(&self) -> &'env Annotations
Gets annotations.
sourcepub fn get_acquires_global_resources(&self) -> &[StructId]
pub fn get_acquires_global_resources(&self) -> &[StructId]
Gets acquired resources
sourcepub fn get_mut_ref_return_index(&self, idx: usize) -> Option<usize>
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.
sourcepub fn get_mut_ref_mapping(&self) -> BTreeMap<TempIndex, usize>
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.
sourcepub fn get_modify_targets_for_type(
&self,
ty: &QualifiedId<StructId>
) -> Option<&Vec<Exp>>
pub fn get_modify_targets_for_type( &self, ty: &QualifiedId<StructId> ) -> Option<&Vec<Exp>>
Gets modify targets for a type
sourcepub fn get_modify_targets(&self) -> &BTreeMap<QualifiedId<StructId>, Vec<Exp>>
pub fn get_modify_targets(&self) -> &BTreeMap<QualifiedId<StructId>, Vec<Exp>>
Gets all modify targets
sourcepub fn get_modify_ids(&self) -> BTreeSet<QualifiedInstId<StructId>>
pub fn get_modify_ids(&self) -> BTreeSet<QualifiedInstId<StructId>>
Get all modifies targets, as instantiated struct ids.
pub fn get_modify_ids_and_exps( &self ) -> BTreeMap<QualifiedInstId<StructId>, Vec<&Exp>>
source§impl<'env> FunctionTarget<'env>
impl<'env> FunctionTarget<'env>
sourcepub fn register_annotation_formatter(&self, formatter: Box<AnnotationFormatter>)
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.
sourcepub fn register_annotation_formatters_for_test(&self)
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.