use crate::SourceLoc;
#[derive(Debug, Clone)]
pub struct FrameInfo {
module_name: String,
func_index: u32,
function_name: Option<String>,
func_start: SourceLoc,
instr: SourceLoc,
}
impl FrameInfo {
pub fn new(
module_name: String,
func_index: u32,
function_name: Option<String>,
func_start: SourceLoc,
instr: SourceLoc,
) -> Self {
Self {
module_name,
func_index,
function_name,
func_start,
instr,
}
}
pub fn func_index(&self) -> u32 {
self.func_index
}
pub fn module_name(&self) -> &str {
&self.module_name
}
pub fn function_name(&self) -> Option<&str> {
self.function_name.as_deref()
}
pub fn module_offset(&self) -> usize {
self.instr.bits() as usize
}
pub fn func_offset(&self) -> usize {
(self.instr.bits() - self.func_start.bits()) as usize
}
}