mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Supply input val to override_unary_op
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user