Struct bytecode_source_map::source_map::FunctionSourceMap
source · 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
impl FunctionSourceMap
pub fn new(decl_location: Loc) -> Self
pub fn add_type_parameter(&mut self, type_name: SourceName)
pub fn get_type_parameter_name( &self, type_parameter_idx: usize ) -> Option<SourceName>
sourcepub fn add_code_mapping(&mut self, start_offset: CodeOffset, location: Loc)
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.
sourcepub fn add_nop_mapping(&mut self, label: NopLabel, offset: CodeOffset)
pub fn add_nop_mapping(&mut self, label: NopLabel, offset: CodeOffset)
Record the code offset for an Nop label
pub fn add_local_mapping(&mut self, name: SourceName)
pub fn add_parameter_mapping(&mut self, name: SourceName)
sourcepub fn get_code_location(&self, code_offset: CodeOffset) -> Option<Loc>
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.
pub fn get_parameter_or_local_name(&self, idx: u64) -> Option<SourceName>
pub fn make_local_name_to_index_map(&self) -> BTreeMap<&String, LocalIndex>
pub fn dummy_function_map( &mut self, view: &BinaryIndexedView<'_>, function_def: &FunctionDefinition, default_loc: Loc ) -> Result<()>
Trait Implementations§
source§impl Clone for FunctionSourceMap
impl Clone for FunctionSourceMap
source§fn clone(&self) -> FunctionSourceMap
fn clone(&self) -> FunctionSourceMap
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more