bytecode evaluation
This commit is contained in:
parent
fb29955f7d
commit
8642dcdd6a
5 changed files with 528 additions and 31 deletions
|
@ -22,19 +22,28 @@ impl Bytecode {
|
|||
0x0E => (Instruction::PushConstDouble0(), 1),
|
||||
0x0F => (Instruction::PushConstDouble1(), 1),
|
||||
|
||||
0x10 => (Instruction::LoadByteImmediate(self.bytes[offset+1]), 2),
|
||||
0x11 => (Instruction::LoadShortImmediate((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
|
||||
0x12 => (Instruction::LoadConstant(self.bytes[offset+1]), 2),
|
||||
0x14 => (Instruction::LoadConstant64((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
|
||||
|
||||
0x26 => (Instruction::LoadDouble0(), 1),
|
||||
0x27 => (Instruction::LoadDouble1(), 1),
|
||||
0x28 => (Instruction::LoadDouble2(), 1),
|
||||
0x29 => (Instruction::LoadDouble3(), 1),
|
||||
0x2A => (Instruction::LoadReference0(), 1),
|
||||
0x2B => (Instruction::LoadReference1(), 1),
|
||||
0x2C => (Instruction::LoadReference2(), 1),
|
||||
0x2D => (Instruction::LoadReference3(), 1),
|
||||
0x1A => (Instruction::LoadLocalInt0(), 1),
|
||||
0x1B => (Instruction::LoadLocalInt1(), 1),
|
||||
0x1C => (Instruction::LoadLocalInt2(), 1),
|
||||
0x1D => (Instruction::LoadLocalInt3(), 1),
|
||||
0x26 => (Instruction::LoadLocalDouble0(), 1),
|
||||
0x27 => (Instruction::LoadLocalDouble1(), 1),
|
||||
0x28 => (Instruction::LoadLocalDouble2(), 1),
|
||||
0x29 => (Instruction::LoadLocalDouble3(), 1),
|
||||
0x2A => (Instruction::LoadLocalReference0(), 1),
|
||||
0x2B => (Instruction::LoadLocalReference1(), 1),
|
||||
0x2C => (Instruction::LoadLocalReference2(), 1),
|
||||
0x2D => (Instruction::LoadLocalReference3(), 1),
|
||||
|
||||
0x3B => (Instruction::StoreLocalInt0(), 1),
|
||||
0x3C => (Instruction::StoreLocalInt1(), 1),
|
||||
0x3D => (Instruction::StoreLocalInt2(), 1),
|
||||
0x3E => (Instruction::StoreLocalInt3(), 1),
|
||||
0x4B => (Instruction::StoreReference0(), 1),
|
||||
0x4C => (Instruction::StoreReference1(), 1),
|
||||
0x4D => (Instruction::StoreReference2(), 1),
|
||||
|
@ -43,6 +52,7 @@ impl Bytecode {
|
|||
0x57 => (Instruction::Pop(), 1),
|
||||
0x59 => (Instruction::Duplicate(), 1),
|
||||
|
||||
0x68 => (Instruction::MultiplyInt(), 1),
|
||||
0x6D => (Instruction::DivideLong(), 1),
|
||||
|
||||
0x7A => (Instruction::ShiftIntRight(), 1),
|
||||
|
@ -105,19 +115,28 @@ pub enum Instruction {
|
|||
PushConstDouble0() = 0x0E, // Push 0.0
|
||||
PushConstDouble1() = 0x0F, // Push 1.0
|
||||
|
||||
LoadByteImmediate(u8) = 0x10, // push immediate short
|
||||
LoadShortImmediate(u16) = 0x11, // push immediate short
|
||||
LoadConstant(u8) = 0x12, // Push from constant pool
|
||||
LoadConstant64(u16) = 0x14, // Push Long or Double from constant pool
|
||||
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
|
||||
|
||||
LoadDouble0() = 0x26, // Load local double variable reference onto stack
|
||||
LoadDouble1() = 0x27, // Load local double variable reference onto stack
|
||||
LoadDouble2() = 0x28, // Load local double variable reference onto stack
|
||||
LoadDouble3() = 0x29, // Load local double variable reference onto stack
|
||||
LoadReference0() = 0x2A, // Load local reference variable reference onto stack
|
||||
LoadReference1() = 0x2B, // Load local reference variable reference onto stack
|
||||
LoadReference2() = 0x2C, // Load local reference variable reference onto stack
|
||||
LoadReference3() = 0x2D, // Load local reference variable reference onto stack
|
||||
LoadLocalDouble0() = 0x26, // Load local double variable reference onto stack
|
||||
LoadLocalDouble1() = 0x27, // Load local double variable reference onto stack
|
||||
LoadLocalDouble2() = 0x28, // Load local double variable reference onto stack
|
||||
LoadLocalDouble3() = 0x29, // Load local double variable reference onto stack
|
||||
LoadLocalReference0() = 0x2A, // Load local reference variable reference onto stack
|
||||
LoadLocalReference1() = 0x2B, // Load local reference variable reference onto stack
|
||||
LoadLocalReference2() = 0x2C, // Load local reference variable reference onto stack
|
||||
LoadLocalReference3() = 0x2D, // Load local reference variable reference onto stack
|
||||
|
||||
StoreLocalInt0() = 0x3B, // store int into local variable
|
||||
StoreLocalInt1() = 0x3C, // store int into local variable
|
||||
StoreLocalInt2() = 0x3D, // store int into local variable
|
||||
StoreLocalInt3() = 0x3E, // store int into local variable
|
||||
StoreReference0() = 0x4B, // store reference into local variable
|
||||
StoreReference1() = 0x4C, // store reference into local variable
|
||||
StoreReference2() = 0x4D, // store reference into local variable
|
||||
|
@ -126,6 +145,7 @@ pub enum Instruction {
|
|||
Pop() = 0x57, // Pop top stack value
|
||||
Duplicate() = 0x59, // duplicate top stack value
|
||||
|
||||
MultiplyInt() = 0x68, // int multiplication
|
||||
DivideLong() = 0x6D, // long division
|
||||
|
||||
ShiftIntRight() = 0x7a, // shift int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue