diff --git a/valuescript_vm/src/operations.rs b/valuescript_vm/src/operations.rs index b1765d9..2dffd6f 100644 --- a/valuescript_vm/src/operations.rs +++ b/valuescript_vm/src/operations.rs @@ -67,7 +67,7 @@ pub fn op_plus(left: &Val, right: &Val) -> Result { } pub fn op_unary_plus(input: &Val) -> Result { - if let Some(res) = input.override_unary_op(UnaryOp::Plus) { + if let Some(res) = input.override_unary_op(UnaryOp::Plus, input) { return res; } @@ -90,7 +90,7 @@ pub fn op_minus(left: &Val, right: &Val) -> Result { } pub fn op_unary_minus(input: &Val) -> Result { - if let Some(res) = input.override_unary_op(UnaryOp::Minus) { + if let Some(res) = input.override_unary_op(UnaryOp::Minus, input) { return res; } @@ -450,7 +450,7 @@ pub fn op_or(left: &Val, right: &Val) -> Result { } pub fn op_not(input: &Val) -> Result { - if let Some(res) = input.override_unary_op(UnaryOp::Not) { + if let Some(res) = input.override_unary_op(UnaryOp::Not, input) { return res; } @@ -592,7 +592,7 @@ pub fn op_bit_or(left: &Val, right: &Val) -> Result { } pub fn op_bit_not(input: &Val) -> Result { - if let Some(res) = input.override_unary_op(UnaryOp::BitNot) { + if let Some(res) = input.override_unary_op(UnaryOp::BitNot, input) { return res; } diff --git a/valuescript_vm/src/vs_value.rs b/valuescript_vm/src/vs_value.rs index 9f17f70..1c6993a 100644 --- a/valuescript_vm/src/vs_value.rs +++ b/valuescript_vm/src/vs_value.rs @@ -111,7 +111,7 @@ pub trait ValTrait: fmt::Display { None } - fn override_unary_op(&self, _op: UnaryOp) -> Option> { + fn override_unary_op(&self, _op: UnaryOp, _input: &Val) -> Option> { None } @@ -595,7 +595,7 @@ impl ValTrait for Val { } } - fn override_unary_op(&self, op: UnaryOp) -> Option> { + fn override_unary_op(&self, op: UnaryOp, input: &Val) -> Option> { match self { Val::Void | Val::Undefined @@ -611,8 +611,8 @@ impl ValTrait for Val { | Val::Class(_) | Val::CopyCounter(_) | Val::StoragePtr(_) => None, - Val::Static(static_) => static_.override_unary_op(op), - Val::Dynamic(dynamic) => dynamic.override_unary_op(op), + Val::Static(static_) => static_.override_unary_op(op, input), + Val::Dynamic(dynamic) => dynamic.override_unary_op(op, input), } }