Implemented VM.initalize and LoadConstant64

This commit is contained in:
vegowotenks 2024-10-29 13:24:26 +01:00
parent b4c33a0d9b
commit 43ceaa95bb
3 changed files with 204 additions and 13 deletions

View file

@ -1045,11 +1045,26 @@ impl JVM {
}
Instruction::InstanceOf(classref_index) => {
// TODO: Class loading checks
let class_name = class.gather_class(classref_index)?;
let object = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;
let object = wrap_stackframe_error(class, method, frame.operand_stack.peek_reference(0))?;
let native_class_name = self.heap_area.object_area.get_reference_native_class_name(object, &self.class_store);
if class_name.starts_with("[") {
// TODO: Create array class on demand
} else {
if ! self.class_store.have_class(class_name) {
frame.instruction_pointer -= offset as u32;
return Ok(JVMCallbackOperation::LoadClass(class_name.to_string()));
}
if ! self.class_store.was_init(class_name).unwrap() {
frame.instruction_pointer -= offset as u32;
return Ok(JVMCallbackOperation::InitClass(class_name.to_string()));
}
}
frame.operand_stack.pop_reference(0).unwrap();
let instruction_result = if class_name == native_class_name {
1
} else {
@ -1449,6 +1464,20 @@ impl JVM {
}
}
Instruction::LoadConstant64(wide_index) => {
match class.pool_entry(wide_index).unwrap() {
ConstantPoolInfo::Long(long_data) => {
let long_value = long_data.value;
wrap_stackframe_error(class, method, frame.operand_stack.push_long(long_value))?;
}
_ => {
println!("{:?}", class.pool_entry(wide_index).unwrap());
todo!()
}
}
}
Instruction::LoadLocalFloat(index) => {
load_local_float(class, method, frame, index as usize)?;
}
@ -1749,6 +1778,12 @@ impl JVM {
FieldValue::Int(int_value)
}
(0, AbstractTypeKind::Long()) => {
let long_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_long(0))?;
FieldValue::Long(long_value)
}
(0..=255, AbstractTypeKind::Classname(_field_type_name)) => {
let ref_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;