Implemented a lot of opcodes and some native methods
This commit is contained in:
parent
4c43e9290f
commit
272a34b7cd
5 changed files with 394 additions and 101 deletions
|
@ -35,12 +35,17 @@ impl Bytecode {
|
|||
0x14 => (Instruction::LoadConstant64((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
|
||||
|
||||
0x15 => (Instruction::LoadLocalInt(self.bytes[offset+1]), 2),
|
||||
0x16 => (Instruction::LoadLocalLong(self.bytes[offset+1]), 2),
|
||||
0x17 => (Instruction::LoadLocalFloat(self.bytes[offset+1]), 2),
|
||||
0x19 => (Instruction::LoadLocalReference(self.bytes[offset+1]), 2),
|
||||
0x1A => (Instruction::LoadLocalInt0(), 1),
|
||||
0x1B => (Instruction::LoadLocalInt1(), 1),
|
||||
0x1C => (Instruction::LoadLocalInt2(), 1),
|
||||
0x1D => (Instruction::LoadLocalInt3(), 1),
|
||||
0x1E => (Instruction::LoadLocalLong0(), 1),
|
||||
0x1F => (Instruction::LoadLocalLong1(), 1),
|
||||
0x20 => (Instruction::LoadLocalLong2(), 1),
|
||||
0x21 => (Instruction::LoadLocalLong3(), 1),
|
||||
0x22 => (Instruction::LoadLocalFloat0(), 1),
|
||||
0x23 => (Instruction::LoadLocalFloat1(), 1),
|
||||
0x24 => (Instruction::LoadLocalFloat2(), 1),
|
||||
|
@ -64,6 +69,10 @@ impl Bytecode {
|
|||
0x3C => (Instruction::StoreLocalInt1(), 1),
|
||||
0x3D => (Instruction::StoreLocalInt2(), 1),
|
||||
0x3E => (Instruction::StoreLocalInt3(), 1),
|
||||
0x3F => (Instruction::StoreLocalLong0(), 1),
|
||||
0x40 => (Instruction::StoreLocalLong1(), 1),
|
||||
0x41 => (Instruction::StoreLocalLong2(), 1),
|
||||
0x42 => (Instruction::StoreLocalLong3(), 1),
|
||||
0x4B => (Instruction::StoreLocalReference0(), 1),
|
||||
0x4C => (Instruction::StoreLocalReference1(), 1),
|
||||
0x4D => (Instruction::StoreLocalReference2(), 1),
|
||||
|
@ -80,11 +89,15 @@ impl Bytecode {
|
|||
|
||||
0x60 => (Instruction::AddInt(), 1),
|
||||
0x64 => (Instruction::SubtractInt(), 1),
|
||||
0x65 => (Instruction::SubtractLong(), 1),
|
||||
0x68 => (Instruction::MultiplyInt(), 1),
|
||||
0x69 => (Instruction::MultiplyLong(), 1),
|
||||
0x6A => (Instruction::MultiplyFloat(), 1),
|
||||
0x6C => (Instruction::DivideInt(), 1),
|
||||
0x6D => (Instruction::DivideLong(), 1),
|
||||
|
||||
0x74 => (Instruction::NegateInt(), 1),
|
||||
0x75 => (Instruction::NegateLong(), 1),
|
||||
0x78 => (Instruction::ArithmeticShiftIntLeft(), 1),
|
||||
0x7A => (Instruction::ArithmeticShiftIntRight(), 1),
|
||||
0x7C => (Instruction::LogicalShiftIntRight(), 1),
|
||||
|
@ -93,10 +106,14 @@ impl Bytecode {
|
|||
0x80 => (Instruction::OrInt(), 1),
|
||||
0x82 => (Instruction::XorInt(), 1),
|
||||
0x84 => (Instruction::IncrementLocalInt(self.bytes[offset+1], i8::from_be_bytes([self.bytes[offset+2]])), 3),
|
||||
0x85 => (Instruction::ConvertIntToLong(), 1),
|
||||
|
||||
0x86 => (Instruction::ConvertIntToFloat(), 1),
|
||||
0x88 => (Instruction::ConvertLongToInt(), 1),
|
||||
0x8B => (Instruction::ConvertFloatToInt(), 1),
|
||||
0x91 => (Instruction::ConvertIntToByte(), 1),
|
||||
0x92 => (Instruction::ConvertIntToChar(), 1),
|
||||
0x94 => (Instruction::CompareLong(), 1),
|
||||
0x95 => (Instruction::CompareFloatL(), 1),
|
||||
0x96 => (Instruction::CompareFloatG(), 1),
|
||||
0x99 => {
|
||||
|
@ -207,6 +224,7 @@ impl Bytecode {
|
|||
(Instruction::LookupSwitch(default, pairs_vec.into()), 1 + padding + 4 + 4 + npairs as usize * 8)
|
||||
}
|
||||
0xAC => (Instruction::ReturnInt(), 1),
|
||||
0xAD => (Instruction::ReturnLong(), 1),
|
||||
|
||||
0xB0 => (Instruction::ReturnReference(), 1),
|
||||
0xB1 => (Instruction::ReturnVoid(), 1),
|
||||
|
@ -289,13 +307,18 @@ pub enum Instruction {
|
|||
LoadCostantWide(u16) = 0x13, // Push from constant pool with wide index, don't load
|
||||
// double or long or whatever
|
||||
LoadConstant64(u16) = 0x14, // Push Long or Double from constant pool
|
||||
LoadLocalInt(u8) = 0x15, // Load int from indexed local variable
|
||||
LoadLocalFloat(u8) = 0x17, // Load int from indexed local variable
|
||||
LoadLocalInt(u8) = 0x15, // Load int from indexed local variable
|
||||
LoadLocalLong(u8) = 0x16, // Load long from indexed local variable
|
||||
LoadLocalFloat(u8) = 0x17, // Load float from indexed local variable
|
||||
LoadLocalReference(u8) = 0x19, // Load reference from indexed local variable
|
||||
LoadLocalInt0() = 0x1A, // Load int from local variable
|
||||
LoadLocalInt1() = 0x1B, // Load int from local variable
|
||||
LoadLocalInt2() = 0x1C, // Load int from local variable
|
||||
LoadLocalInt3() = 0x1D, // Load int from local variable
|
||||
LoadLocalLong0() = 0x1E, // load long from local variable
|
||||
LoadLocalLong1() = 0x1F, // load long from local variable
|
||||
LoadLocalLong2() = 0x20, // load long from local variable
|
||||
LoadLocalLong3() = 0x21, // load long from local variable
|
||||
|
||||
LoadLocalFloat0() = 0x22, // Load local double variable reference onto stack
|
||||
LoadLocalFloat1() = 0x23, // Load local double variable reference onto stack
|
||||
|
@ -320,6 +343,10 @@ pub enum Instruction {
|
|||
StoreLocalInt1() = 0x3C, // store int into local variable
|
||||
StoreLocalInt2() = 0x3D, // store int into local variable
|
||||
StoreLocalInt3() = 0x3E, // store int into local variable
|
||||
StoreLocalLong0() = 0x3F, // store int into local variable
|
||||
StoreLocalLong1() = 0x40, // store int into local variable
|
||||
StoreLocalLong2() = 0x41, // store int into local variable
|
||||
StoreLocalLong3() = 0x42, // store int into local variable
|
||||
StoreLocalReference0() = 0x4B, // store reference into local variable
|
||||
StoreLocalReference1() = 0x4C, // store reference into local variable
|
||||
StoreLocalReference2() = 0x4D, // store reference into local variable
|
||||
|
@ -335,11 +362,15 @@ pub enum Instruction {
|
|||
|
||||
AddInt() = 0x60, // int addition
|
||||
SubtractInt() = 0x64, // int subtraction
|
||||
SubtractLong() = 0x65, // long subtraction
|
||||
MultiplyInt() = 0x68, // int multiplication
|
||||
MultiplyLong() = 0x69, // long multiplication
|
||||
MultiplyFloat() = 0x6A, // float multiplication
|
||||
DivideInt() = 0x6C, // integer division, round toward zero and more rules
|
||||
DivideLong() = 0x6D, // long division
|
||||
|
||||
NegateInt() = 0x74, // arithmetic negation
|
||||
NegateLong() = 0x75, // arithmetic negation
|
||||
ArithmeticShiftIntLeft() = 0x78, // shift int left, preserve sign
|
||||
ArithmeticShiftIntRight() = 0x7A, // shift int right, preserve sign
|
||||
LogicalShiftIntRight() = 0x7C, // shift int right with zero extension
|
||||
|
@ -348,10 +379,14 @@ pub enum Instruction {
|
|||
OrInt() = 0x80, // value, value => or
|
||||
XorInt() = 0x82, // value, value => xor
|
||||
IncrementLocalInt(u8, i8) = 0x84, // increment local variable by constant i8
|
||||
ConvertIntToLong() = 0x85, // convert int on stack to long
|
||||
|
||||
ConvertIntToFloat() = 0x86, // change data type
|
||||
ConvertLongToInt() = 0x88, // change data type
|
||||
ConvertFloatToInt() = 0x8B, // change data type
|
||||
ConvertIntToByte() = 0x91, // truncate int to 8 bits
|
||||
ConvertIntToChar() = 0x92, // truncate int to 16 bits
|
||||
CompareLong() = 0x94, // compare long
|
||||
CompareFloatL() = 0x95, // 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
|
||||
|
@ -374,6 +409,7 @@ pub enum Instruction {
|
|||
TableSwitch(i32, i32, i32, Box<[i32]>) = 0xAA, // jump based on indexed range
|
||||
LookupSwitch(i32, Box<[(i32, i32)]>) = 0xAB, // jump based on switch value
|
||||
ReturnInt() = 0xAC, // return integer from function
|
||||
ReturnLong() = 0xAD, // return long from function
|
||||
|
||||
ReturnReference() = 0xB0, // return top-ref from current function
|
||||
ReturnVoid() = 0xB1, // return void from function
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue