Implemented some more native methods
This commit is contained in:
parent
272a34b7cd
commit
aba29af0a3
5 changed files with 198 additions and 6 deletions
26
src/jvm.rs
26
src/jvm.rs
|
@ -474,8 +474,7 @@ impl JVM {
|
|||
let class_name = waiting_queue.pop_front().unwrap();
|
||||
|
||||
if ! self.class_store.have_class(&class_name) {
|
||||
println!("Loading Class {class_name}");
|
||||
self.load_class(&class_name)?;
|
||||
let new_class_index = self.load_class(&class_name)?;
|
||||
let (file, _) = self.class_store.get_class(&class_name).unwrap();
|
||||
if file.has_super_class() {
|
||||
waiting_queue.push_back(file.get_super_class_name()?.to_string());
|
||||
|
@ -485,6 +484,7 @@ impl JVM {
|
|||
let interface_name = file.gather_class(*interface_index)?;
|
||||
waiting_queue.push_back(interface_name.to_string());
|
||||
}
|
||||
println!("Loaded Class {class_name} ({new_class_index})");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ impl JVM {
|
|||
let (instruction, offset) = bytecode.next_instruction(frame.instruction_pointer as usize);
|
||||
frame.instruction_pointer += offset as u32;
|
||||
|
||||
//println!("{} locals: {:?}", " ".repeat(frame_index), frame.locals);
|
||||
println!("{} locals: {:?}", " ".repeat(frame_index), frame.locals);
|
||||
println!("{} stack: {:?}", " ".repeat(frame_index), frame.operand_stack);
|
||||
println!("{}{}.{}:{:<10}{instruction:?}\n", " ".repeat(frame_index), class.get_classname().unwrap(), method.name, frame.instruction_pointer);
|
||||
|
||||
|
@ -1484,6 +1484,19 @@ impl JVM {
|
|||
array_ref
|
||||
} else {
|
||||
let mut test_type = array_type_desc.super_component();
|
||||
|
||||
if component_name.len() != 1 {
|
||||
let base_type_name = test_type.extract_class_name();
|
||||
if ! self.class_store.have_class(base_type_name) {
|
||||
frame.instruction_pointer -= offset as u32;
|
||||
return Ok(JVMCallbackOperation::LoadClass(base_type_name.to_string()));
|
||||
}
|
||||
if ! self.class_store.was_init(base_type_name).unwrap() {
|
||||
frame.instruction_pointer -= offset as u32;
|
||||
return Ok(JVMCallbackOperation::InitClass(base_type_name.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
let mut test_object_ref = self.class_store.class_ref_for_type(test_type.clone()).unwrap();
|
||||
|
||||
while let Some(new_test_object_ref) = self.class_store.class_ref_for_type(test_type.array()) {
|
||||
|
@ -1844,7 +1857,12 @@ impl JVM {
|
|||
let value = match expected_field_descriptor.as_str() {
|
||||
"J" | "D" => wrap_stackframe_error(class, method, frame.operand_stack.pop_computational_2(0))?,
|
||||
_ => match wrap_stackframe_error(class, method, frame.operand_stack.pop_computational_1(0))? {
|
||||
StackValue::Int(i) => FieldValue::Int(i),
|
||||
StackValue::Int(i) => {
|
||||
match expected_field_descriptor.as_str() {
|
||||
"Z" => FieldValue::Boolean(i != 0),
|
||||
_ => FieldValue::Int(i)
|
||||
}
|
||||
}
|
||||
StackValue::Reference(r) => FieldValue::Reference(r),
|
||||
StackValue::Float(f) => FieldValue::Float(f),
|
||||
StackValue::Byte(b) => FieldValue::Byte(b),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue