mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-12 23:18:03 -05:00
Enable voids in bytecode
This commit is contained in:
@@ -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>) -> 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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user