Skip to content

Commit

Permalink
Supply input val to override_unary_op
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 17, 2024
1 parent 27115c3 commit 357c31f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions valuescript_vm/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn op_plus(left: &Val, right: &Val) -> Result<Val, Val> {
}

pub fn op_unary_plus(input: &Val) -> Result<Val, Val> {
if let Some(res) = input.override_unary_op(UnaryOp::Plus) {
if let Some(res) = input.override_unary_op(UnaryOp::Plus, input) {
return res;
}

Expand All @@ -90,7 +90,7 @@ pub fn op_minus(left: &Val, right: &Val) -> Result<Val, Val> {
}

pub fn op_unary_minus(input: &Val) -> Result<Val, Val> {
if let Some(res) = input.override_unary_op(UnaryOp::Minus) {
if let Some(res) = input.override_unary_op(UnaryOp::Minus, input) {
return res;
}

Expand Down Expand Up @@ -450,7 +450,7 @@ pub fn op_or(left: &Val, right: &Val) -> Result<Val, Val> {
}

pub fn op_not(input: &Val) -> Result<Val, Val> {
if let Some(res) = input.override_unary_op(UnaryOp::Not) {
if let Some(res) = input.override_unary_op(UnaryOp::Not, input) {
return res;
}

Expand Down Expand Up @@ -592,7 +592,7 @@ pub fn op_bit_or(left: &Val, right: &Val) -> Result<Val, Val> {
}

pub fn op_bit_not(input: &Val) -> Result<Val, Val> {
if let Some(res) = input.override_unary_op(UnaryOp::BitNot) {
if let Some(res) = input.override_unary_op(UnaryOp::BitNot, input) {
return res;
}

Expand Down
8 changes: 4 additions & 4 deletions valuescript_vm/src/vs_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub trait ValTrait: fmt::Display {
None
}

fn override_unary_op(&self, _op: UnaryOp) -> Option<Result<Val, Val>> {
fn override_unary_op(&self, _op: UnaryOp, _input: &Val) -> Option<Result<Val, Val>> {
None
}

Expand Down Expand Up @@ -595,7 +595,7 @@ impl ValTrait for Val {
}
}

fn override_unary_op(&self, op: UnaryOp) -> Option<Result<Val, Val>> {
fn override_unary_op(&self, op: UnaryOp, input: &Val) -> Option<Result<Val, Val>> {
match self {
Val::Void
| Val::Undefined
Expand All @@ -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),
}
}

Expand Down

0 comments on commit 357c31f

Please sign in to comment.