diff --git a/src/vstc/virtual_machine/bytecode_decoder.rs b/src/vstc/virtual_machine/bytecode_decoder.rs index 8bc4999..1f7f9d8 100644 --- a/src/vstc/virtual_machine/bytecode_decoder.rs +++ b/src/vstc/virtual_machine/bytecode_decoder.rs @@ -17,6 +17,7 @@ pub struct BytecodeDecoder { #[derive(PartialEq)] pub enum BytecodeType { End = 0x00, + Void = 0x01, Undefined = 0x02, Null = 0x03, False = 0x04, @@ -37,6 +38,7 @@ impl BytecodeType { return match byte { 0x00 => End, + 0x01 => Void, 0x02 => Undefined, 0x03 => Null, 0x04 => False, @@ -77,6 +79,7 @@ impl BytecodeDecoder { pub fn decode_val(&mut self, registers: &Vec) -> Val { return match self.decode_type() { BytecodeType::End => std::panic!("Cannot decode end"), + BytecodeType::Void => Val::Void, BytecodeType::Undefined => Val::Undefined, BytecodeType::Null => Val::Null, BytecodeType::False => Val::Bool(false), diff --git a/src/vstc/virtual_machine/operations.rs b/src/vstc/virtual_machine/operations.rs index d964fb0..222bb78 100644 --- a/src/vstc/virtual_machine/operations.rs +++ b/src/vstc/virtual_machine/operations.rs @@ -260,7 +260,12 @@ pub fn op_sub(left: Val, right: Val) -> Val { return Val::Undefined; } - return array_data[right_index].clone(); + let res = array_data[right_index].clone(); + + return match res { + Val::Void => Val::Undefined, + _ => res, + }; }, Val::Object(object_data) => { return object_data diff --git a/src/vstc/virtual_machine/vs_pointer.rs b/src/vstc/virtual_machine/vs_pointer.rs index 68de7c9..1e6606c 100644 --- a/src/vstc/virtual_machine/vs_pointer.rs +++ b/src/vstc/virtual_machine/vs_pointer.rs @@ -34,6 +34,7 @@ impl ValTrait for VsPointer { return match bd.decode_type() { BytecodeType::End => std::panic!("Invalid: pointer to end"), + BytecodeType::Void => std::panic!("Invalid: pointer to void"), BytecodeType::Undefined => VsType::Undefined, BytecodeType::Null => VsType::Null, BytecodeType::False => VsType::Bool,