Implemented java/lang/Throwable.fill_in_stacktrace
This commit is contained in:
parent
d38d5b2897
commit
45d0aa66e5
2 changed files with 128 additions and 2 deletions
|
@ -375,6 +375,22 @@ impl JavaClassFile {
|
|||
|
||||
return Ok((class_name, method_name, method_descriptor));
|
||||
}
|
||||
|
||||
pub fn sourcefile(&self) -> Result<Option<&String>, Error> {
|
||||
match self.attributes.into_iter()
|
||||
.filter_map(|attribute| match &attribute.data {
|
||||
AttributeData::SourceFile(data) => Some(data),
|
||||
_ => None,
|
||||
})
|
||||
.next() {
|
||||
None => Ok(None),
|
||||
Some(data) => {
|
||||
let sourcefile_name = &self.pool_utf8_entry(data.source_file_index)?.utf8;
|
||||
|
||||
Ok(Some(sourcefile_name))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -953,6 +969,13 @@ impl AbstractTypeDescription {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn class_type(class: &str) -> AbstractTypeDescription {
|
||||
AbstractTypeDescription {
|
||||
array_level: 0,
|
||||
kind: AbstractTypeKind::Classname(class.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
@ -1078,6 +1101,23 @@ impl MethodInfo {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_bytecode_linenumber(&self, bytecode_index: u16) -> Option<u16> {
|
||||
let linenumbertable = match self.attributes
|
||||
.into_iter()
|
||||
.filter_map(|a| match &a.data {
|
||||
AttributeData::LineNumberTable(data) => Some(data),
|
||||
_ => None,
|
||||
})
|
||||
.next() {
|
||||
Some(a) => a,
|
||||
None => return None,
|
||||
};
|
||||
linenumbertable.entries.into_iter()
|
||||
.take_while(|entry| entry.start_pc < bytecode_index)
|
||||
.map(|entry| entry.line_number)
|
||||
.last()
|
||||
}
|
||||
|
||||
pub fn get_code_attribute(&self) -> Option<&CodeAttributeData> {
|
||||
return if self.code_attribute_index != self.attributes.len() {
|
||||
match &self.attributes[self.code_attribute_index].data {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue