Find implementation of invokeinterface method
This commit is contained in:
parent
9190d3f7e7
commit
49ce37402e
1 changed files with 18 additions and 15 deletions
33
src/jvm.rs
33
src/jvm.rs
|
@ -1019,19 +1019,9 @@ impl JVM {
|
||||||
let target_interface_class_index = self.class_store.class_idx_from_name(supplied_interface_name).unwrap();
|
let target_interface_class_index = self.class_store.class_idx_from_name(supplied_interface_name).unwrap();
|
||||||
|
|
||||||
let parsed_expected_descriptor: MethodDescriptor = MethodDescriptor::try_from(supplied_descriptor_string)?;
|
let parsed_expected_descriptor: MethodDescriptor = MethodDescriptor::try_from(supplied_descriptor_string)?;
|
||||||
let (class_index, method_index, method_info) = match ClassMethodIterator::new(target_interface_class_index, &self.class_store)
|
|
||||||
.filter(|(_cid, _mid, minfo)| minfo.name == *supplied_method_name)
|
|
||||||
.filter(|(_cid, _mid, minfo)| minfo.descriptor == parsed_expected_descriptor)
|
|
||||||
.next() {
|
|
||||||
Some(m) => m,
|
|
||||||
None => {
|
|
||||||
// TODO: Throw exception
|
|
||||||
return Err(Error::RunTimeError(format!("InvokeInterface: Failed to find requested method '{}' with descriptor '{}' in the class '{}'", supplied_method_name, supplied_descriptor_string, supplied_interface_name)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut arguments = VecDeque::new();
|
let mut arguments = VecDeque::new();
|
||||||
fill_arguments(class, method, &mut arguments, &method_info.descriptor.argument_types, &mut frame.operand_stack)?;
|
fill_arguments(class, method, &mut arguments, &parsed_expected_descriptor.argument_types, &mut frame.operand_stack)?;
|
||||||
let this_object = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;
|
let this_object = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;
|
||||||
arguments.push_front(StackValue::Reference(this_object));
|
arguments.push_front(StackValue::Reference(this_object));
|
||||||
|
|
||||||
|
@ -1048,11 +1038,24 @@ impl JVM {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: I hate this, now I have to find the 'implementation' of a function
|
// TODO: Filter abstract
|
||||||
let interface_class_file = self.class_store.class_file_from_idx(target_interface_class_index).unwrap();
|
// TODO: Check method info match
|
||||||
|
let (class_index, method_index, _method_info) = match ClassMethodIterator::new(object_class_index, &self.class_store)
|
||||||
|
.filter(|(_cid, _mid, minfo)| minfo.name == *supplied_method_name)
|
||||||
|
.filter(|(_cid, _mid, minfo)| minfo.descriptor == parsed_expected_descriptor)
|
||||||
|
.next() {
|
||||||
|
Some(m) => m,
|
||||||
|
None => {
|
||||||
|
// TODO: Throw exception
|
||||||
|
return Err(Error::RunTimeError(format!("InvokeInterface: Failed to find requested implementation of method '{}' with descriptor '{}' in the class '{}'", supplied_method_name, supplied_descriptor_string, supplied_interface_name)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let implementing_class_file = self.class_store.class_file_from_idx(class_index).unwrap();
|
||||||
let interface_frame = StackFrame::new(
|
let interface_frame = StackFrame::new(
|
||||||
interface_class_file,
|
implementing_class_file,
|
||||||
target_interface_class_index,
|
class_index,
|
||||||
method_index as u16,
|
method_index as u16,
|
||||||
arguments.make_contiguous()
|
arguments.make_contiguous()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue