Implement ConvertIntToChar
This commit is contained in:
parent
95beeef1c5
commit
202d7692bc
2 changed files with 9 additions and 0 deletions
|
@ -88,6 +88,7 @@ impl Bytecode {
|
||||||
0x82 => (Instruction::XorInt(), 1),
|
0x82 => (Instruction::XorInt(), 1),
|
||||||
0x84 => (Instruction::IncrementLocalInt(self.bytes[offset+1], i8::from_be_bytes([self.bytes[offset+2]])), 3),
|
0x84 => (Instruction::IncrementLocalInt(self.bytes[offset+1], i8::from_be_bytes([self.bytes[offset+2]])), 3),
|
||||||
|
|
||||||
|
0x92 => (Instruction::ConvertIntToChar(), 1),
|
||||||
0x95 => (Instruction::CompareFloatL(), 1),
|
0x95 => (Instruction::CompareFloatL(), 1),
|
||||||
0x96 => (Instruction::CompareFloatG(), 1),
|
0x96 => (Instruction::CompareFloatG(), 1),
|
||||||
0x99 => {
|
0x99 => {
|
||||||
|
@ -334,6 +335,7 @@ pub enum Instruction {
|
||||||
XorInt() = 0x82, // value, value => xor
|
XorInt() = 0x82, // value, value => xor
|
||||||
IncrementLocalInt(u8, i8) = 0x84, // increment local variable by constant i8
|
IncrementLocalInt(u8, i8) = 0x84, // increment local variable by constant i8
|
||||||
|
|
||||||
|
ConvertIntToChar() = 0x92, // truncate int to 16 bits
|
||||||
CompareFloatL() = 0x95, // compare float, push -1 if one is NaN
|
CompareFloatL() = 0x95, // compare float, push -1 if one is NaN
|
||||||
CompareFloatG() = 0x96, // compare float, push 1 if one is NaN
|
CompareFloatG() = 0x96, // compare float, push 1 if one is NaN
|
||||||
BranchZero(i16) = 0x99, // branch if value == 0
|
BranchZero(i16) = 0x99, // branch if value == 0
|
||||||
|
|
|
@ -914,6 +914,13 @@ impl JVM {
|
||||||
wrap_stackframe_error(class, method, frame.operand_stack.push(StackValue::Int(comparison_result)))?;
|
wrap_stackframe_error(class, method, frame.operand_stack.push(StackValue::Int(comparison_result)))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Instruction::ConvertIntToChar() => {
|
||||||
|
let int_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||||
|
let char_value = int_value & 0x0000FFFF;
|
||||||
|
|
||||||
|
frame.operand_stack.push(StackValue::Int(char_value)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
Instruction::DivideInt() => {
|
Instruction::DivideInt() => {
|
||||||
// TODO: Obey all the rules
|
// TODO: Obey all the rules
|
||||||
let quotient = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
let quotient = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?;
|
||||||
|
|
Loading…
Reference in a new issue