Fix build.

This commit is contained in:
Stephen Chung 2023-03-08 22:03:03 +08:00
parent 8fe5bac3e9
commit 80917bfad2
3 changed files with 22 additions and 15 deletions

View File

@ -11,8 +11,10 @@ mod target;
pub use cache::{Caches, FnResolutionCache, FnResolutionCacheEntry};
#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))]
pub use chaining::ChainType;
#[cfg(not(feature = "unchecked"))]
#[cfg(not(feature = "no_index"))]
pub use data_check::calc_array_sizes;
#[cfg(not(feature = "unchecked"))]
#[cfg(not(feature = "no_object"))]
pub use data_check::calc_map_sizes;
#[cfg(feature = "debugging")]

View File

@ -1576,6 +1576,11 @@ impl Engine {
.0
.flatten();
match value.0 {
Union::Bool(b, ..) => return Ok((!b).into()),
_ => (),
}
return value.as_bool().map(|r| (!r).into()).or_else(|_| {
let operand = &mut [&mut value];
self.exec_fn_call(
@ -1597,6 +1602,8 @@ impl Engine {
.0
.flatten();
// For extremely simple primary data operations, do it directly
// to avoid the overhead of calling a function.
match (&lhs.0, &rhs.0) {
(Union::Unit(..), Union::Unit(..)) => match op_token.unwrap() {
Token::EqualsTo => return Ok(Dynamic::TRUE),
@ -1623,6 +1630,7 @@ impl Engine {
#[allow(clippy::wildcard_imports)]
use crate::packages::arithmetic::arith_basic::INT::functions::*;
#[cfg(not(feature = "unchecked"))]
match op_token.unwrap() {
Token::EqualsTo => return Ok((*n1 == *n2).into()),
Token::NotEqualsTo => return Ok((*n1 != *n2).into()),
@ -1630,29 +1638,26 @@ impl Engine {
Token::GreaterThanEqualsTo => return Ok((*n1 >= *n2).into()),
Token::LessThan => return Ok((*n1 < *n2).into()),
Token::LessThanEqualsTo => return Ok((*n1 <= *n2).into()),
#[cfg(not(feature = "unchecked"))]
Token::Plus => return add(*n1, *n2).map(Into::into),
#[cfg(not(feature = "unchecked"))]
Token::Minus => return subtract(*n1, *n2).map(Into::into),
#[cfg(not(feature = "unchecked"))]
Token::Multiply => return multiply(*n1, *n2).map(Into::into),
#[cfg(not(feature = "unchecked"))]
Token::Divide => return divide(*n1, *n2).map(Into::into),
#[cfg(not(feature = "unchecked"))]
Token::Modulo => return modulo(*n1, *n2).map(Into::into),
#[cfg(feature = "unchecked")]
_ => (),
}
#[cfg(feature = "unchecked")]
match op_token.unwrap() {
Token::EqualsTo => return Ok((*n1 == *n2).into()),
Token::NotEqualsTo => return Ok((*n1 != *n2).into()),
Token::GreaterThan => return Ok((*n1 > *n2).into()),
Token::GreaterThanEqualsTo => return Ok((*n1 >= *n2).into()),
Token::LessThan => return Ok((*n1 < *n2).into()),
Token::LessThanEqualsTo => return Ok((*n1 <= *n2).into()),
Token::Plus => return Ok((*n1 + *n2).into()),
#[cfg(feature = "unchecked")]
Token::Minus => return Ok((*n1 - *n2).into()),
#[cfg(feature = "unchecked")]
Token::Multiply => return Ok((*n1 * *n2).into()),
#[cfg(feature = "unchecked")]
Token::Divide => return Ok((*n1 / *n2).into()),
#[cfg(feature = "unchecked")]
Token::Modulo => return Ok((*n1 % *n2).into()),
_ => (),
}
}

View File

@ -2,7 +2,7 @@
use crate::api::deprecated::deprecated_array_functions;
use crate::engine::OP_EQUALS;
use crate::eval::{calc_index, calc_offset_len, calc_array_sizes};
use crate::eval::{calc_index, calc_offset_len};
use crate::module::ModuleFlags;
use crate::plugin::*;
@ -238,7 +238,7 @@ pub mod array_functions {
#[cfg(not(feature = "unchecked"))]
if _ctx.engine().max_array_size() > 0 {
let pad = len - array.len();
let (a, m, s) = calc_array_sizes(array);
let (a, m, s) = crate::eval::calc_array_sizes(array);
let (ax, mx, sx) = item.calc_data_sizes(true);
_ctx.engine()