Supply input val to override_unary_op

This commit is contained in:
Andrew Morris
2024-07-17 10:12:34 +09:00
parent 27115c3e24
commit 357c31f117
2 changed files with 8 additions and 8 deletions

View File

@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}

View File

@@ -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
}
@@ -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
@@ -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),
}
}