pub struct FunctionSourceMap {
    pub decl_location: Loc,
    pub type_parameters: Vec<SourceName>,
    pub parameters: Vec<SourceName>,
    pub locals: Vec<SourceName>,
    pub nops: BTreeMap<NopLabel, CodeOffset>,
    pub code_map: BTreeMap<CodeOffset, Loc>,
}

Fields§

§decl_location: Loc

The source location for the definition of this entire function. Note that in certain instances this will have no valid source location e.g. the “main” function for modules that are treated as programs are synthesized and therefore have no valid source location.

§type_parameters: Vec<SourceName>

Note that type parameters need to be added in the order of their declaration

§parameters: Vec<SourceName>§locals: Vec<SourceName>

The index into the vector is the locals index. The corresponding (Identifier, Location) tuple is the name and location of the local.

§nops: BTreeMap<NopLabel, CodeOffset>

A map to the code offset for a corresponding nop. Nop’s are used as markers for some high level language information

§code_map: BTreeMap<CodeOffset, Loc>

The source location map for the function body.

Implementations§

source§

impl FunctionSourceMap

source

pub fn new(decl_location: Loc) -> Self

source

pub fn add_type_parameter(&mut self, type_name: SourceName)

source

pub fn get_type_parameter_name( &self, type_parameter_idx: usize ) -> Option<SourceName>

source

pub fn add_code_mapping(&mut self, start_offset: CodeOffset, location: Loc)

A single source-level instruction may possibly map to a number of bytecode instructions. In order to not store a location for each instruction, we instead use a BTreeMap to represent a segment map (holding the left-hand-sides of each segment). Thus, an instruction sequence is always marked from its starting point. To determine what part of the source code corresponds to a given CodeOffset we query to find the element that is the largest number less than or equal to the query. This will give us the location for that bytecode range.

source

pub fn add_nop_mapping(&mut self, label: NopLabel, offset: CodeOffset)

Record the code offset for an Nop label

source

pub fn add_local_mapping(&mut self, name: SourceName)

source

pub fn add_parameter_mapping(&mut self, name: SourceName)

source

pub fn get_code_location(&self, code_offset: CodeOffset) -> Option<Loc>

Recall that we are using a segment tree. We therefore lookup the location for the code offset by performing a range query for the largest number less than or equal to the code offset passed in.

source

pub fn get_parameter_or_local_name(&self, idx: u64) -> Option<SourceName>

source

pub fn make_local_name_to_index_map(&self) -> BTreeMap<&String, LocalIndex>

source

pub fn dummy_function_map( &mut self, view: &BinaryIndexedView<'_>, function_def: &FunctionDefinition, default_loc: Loc ) -> Result<()>

Trait Implementations§

source§

impl Clone for FunctionSourceMap

source§

fn clone(&self) -> FunctionSourceMap

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 FunctionSourceMap

source§

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

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

impl<'de> Deserialize<'de> for FunctionSourceMap

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for FunctionSourceMap

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. 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, 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> 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, 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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,