Implemented Exception Throwing
This commit is contained in:
parent
f5428c79b2
commit
8e5b6bb2b8
5 changed files with 224 additions and 9 deletions
18
src/jvm.rs
18
src/jvm.rs
|
@ -1403,7 +1403,7 @@ impl JVM {
|
|||
},
|
||||
|
||||
Instruction::InvokeStatic(methodref_index) => {
|
||||
let (supplied_class_name, supplied_method_name, supplied_descriptor_string) = class.gather_methodref(methodref_index)?;
|
||||
let (supplied_class_name, supplied_method_name, supplied_descriptor_string) = class.gather_methodref_compatible(methodref_index)?;
|
||||
|
||||
if ! self.class_store.have_class(supplied_class_name) {
|
||||
// rewind the bytecode offset, I'll need to execute this instruction again
|
||||
|
@ -1842,6 +1842,15 @@ impl JVM {
|
|||
wrap_stackframe_error(class, method, frame.operand_stack.push_long(result))?;
|
||||
}
|
||||
|
||||
Instruction::ModuloInt() => {
|
||||
let int_1 = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||
let int_2 = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||
|
||||
let modulo = int_2.wrapping_rem(int_1);
|
||||
|
||||
wrap_stackframe_error(class, method, frame.operand_stack.push(StackValue::Int(modulo)))?;
|
||||
}
|
||||
|
||||
Instruction::NegateInt() => {
|
||||
let int = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||
let negated = -int;
|
||||
|
@ -2020,6 +2029,7 @@ impl JVM {
|
|||
match expected_field_descriptor.as_str() {
|
||||
"Z" => FieldValue::Boolean(i != 0),
|
||||
"B" => FieldValue::Byte(i as i8),
|
||||
"C" => FieldValue::Char(i as u16),
|
||||
_ => FieldValue::Int(i)
|
||||
}
|
||||
}
|
||||
|
@ -2126,7 +2136,7 @@ impl JVM {
|
|||
_ => return Err(Error::OpcodeError(format!("Found opcode '{:?}' on method returning '{:?}'", instruction, method.descriptor.return_type)))
|
||||
}
|
||||
|
||||
let int = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||
let int = wrap_stackframe_error(class, method, frame.operand_stack.pop_int_compatible(0))?;
|
||||
|
||||
return Ok(JVMCallbackOperation::ReturnFrame(FieldValue::Int(int)));
|
||||
}
|
||||
|
@ -2429,8 +2439,8 @@ fn fill_arguments(class: &JavaClassFile, method: &MethodInfo, arguments: &mut Ve
|
|||
wrap_stackframe_error(
|
||||
class,
|
||||
method,
|
||||
stack.pop_char(0)
|
||||
)? as i32
|
||||
stack.pop_int_compatible(0)
|
||||
)?
|
||||
)
|
||||
)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue