stdout und stderr encoding

This commit is contained in:
vegowotenks 2024-10-22 13:01:20 +02:00
parent 022bfe9ee6
commit b4c33a0d9b
4 changed files with 116 additions and 6 deletions

View file

@ -35,6 +35,7 @@ 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),
0x17 => (Instruction::LoadLocalFloat(self.bytes[offset+1]), 2),
0x19 => (Instruction::LoadLocalReference(self.bytes[offset+1]), 2),
0x1A => (Instruction::LoadLocalInt0(), 1),
0x1B => (Instruction::LoadLocalInt1(), 1),
@ -56,6 +57,7 @@ impl Bytecode {
0x32 => (Instruction::ArrayElement(), 1),
0x33 => (Instruction::LoadFromBArray(), 1),
0x36 => (Instruction::StoreLocalInt(self.bytes[offset+1]), 2),
0x38 => (Instruction::StoreLocalFloat(self.bytes[offset+1]), 2),
0x3A => (Instruction::StoreLocalReference(self.bytes[offset+1]), 2),
0x3B => (Instruction::StoreLocalInt0(), 1),
0x3C => (Instruction::StoreLocalInt1(), 1),
@ -72,10 +74,12 @@ impl Bytecode {
0x57 => (Instruction::Pop(), 1),
0x59 => (Instruction::Duplicate(), 1),
0x5A => (Instruction::DuplicateInsertDown(), 1),
0x60 => (Instruction::AddInt(), 1),
0x64 => (Instruction::SubtractInt(), 1),
0x68 => (Instruction::MultiplyInt(), 1),
0x6A => (Instruction::MultiplyFloat(), 1),
0x6C => (Instruction::DivideInt(), 1),
0x6D => (Instruction::DivideLong(), 1),
@ -88,6 +92,8 @@ impl Bytecode {
0x82 => (Instruction::XorInt(), 1),
0x84 => (Instruction::IncrementLocalInt(self.bytes[offset+1], i8::from_be_bytes([self.bytes[offset+2]])), 3),
0x86 => (Instruction::ConvertIntToFloat(), 1),
0x8B => (Instruction::ConvertFloatToInt(), 1),
0x92 => (Instruction::ConvertIntToChar(), 1),
0x95 => (Instruction::CompareFloatL(), 1),
0x96 => (Instruction::CompareFloatG(), 1),
@ -209,7 +215,7 @@ impl Bytecode {
0xB6 => (Instruction::InvokeVirtual((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xB7 => (Instruction::InvokeSpecial((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xB8 => (Instruction::InvokeStatic((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xB9 => (Instruction::InvokeInterface((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xB9 => (Instruction::InvokeInterface((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 5), // TODO: Figure out the additional arguments
0xBA => (Instruction::InvokeDynamic((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16, (self.bytes[offset+3] as u16) << 8 | self.bytes[offset+4] as u16), 5),
0xBB => (Instruction::NewObject((self.bytes[offset+1] as u16) << 8 | self.bytes[offset+2] as u16), 3),
0xBC => (Instruction::NewPrimitiveArray(self.bytes[offset+1]), 2),
@ -282,6 +288,7 @@ pub enum Instruction {
// 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
LoadLocalReference(u8) = 0x19, // Load reference from indexed local variable
LoadLocalInt0() = 0x1A, // Load int from local variable
LoadLocalInt1() = 0x1B, // Load int from local variable
@ -304,6 +311,7 @@ pub enum Instruction {
ArrayElement() = 0x32, // load element from array
LoadFromBArray() = 0x33, // store into byte array
StoreLocalInt(u8) = 0x36, // store into indexed local variable
StoreLocalFloat(u8) = 0x38, // store into indexed local variable
StoreLocalReference(u8) = 0x3A, // store into indexed local variable
StoreLocalInt0() = 0x3B, // store int into local variable
StoreLocalInt1() = 0x3C, // store int into local variable
@ -319,10 +327,12 @@ pub enum Instruction {
StoreIntoCArray() = 0x55, // store value into char array
Pop() = 0x57, // Pop top stack value
Duplicate() = 0x59, // duplicate top stack value
DuplicateInsertDown() = 0x5A, // duplicate top stack value and insert two low
AddInt() = 0x60, // int addition
SubtractInt() = 0x64, // int subtraction
MultiplyInt() = 0x68, // int multiplication
MultiplyFloat() = 0x6A, // float multiplication
DivideInt() = 0x6C, // integer division, round toward zero and more rules
DivideLong() = 0x6D, // long division
@ -335,6 +345,8 @@ pub enum Instruction {
XorInt() = 0x82, // value, value => xor
IncrementLocalInt(u8, i8) = 0x84, // increment local variable by constant i8
ConvertIntToFloat() = 0x86, // change data type
ConvertFloatToInt() = 0x8B, // change data type
ConvertIntToChar() = 0x92, // truncate int to 16 bits
CompareFloatL() = 0x95, // compare float, push -1 if one is NaN
CompareFloatG() = 0x96, // compare float, push 1 if one is NaN