Fix builds.

This commit is contained in:
Stephen Chung 2021-12-15 12:46:25 +08:00
parent 7afec287d8
commit eda80488d5
2 changed files with 37 additions and 21 deletions

View File

@ -13,8 +13,8 @@ use crate::r#unsafe::unsafe_cast_var_name_to_lifetime;
use crate::tokenizer::Token; use crate::tokenizer::Token;
use crate::types::dynamic::{map_std_type_name, AccessMode, Union, Variant}; use crate::types::dynamic::{map_std_type_name, AccessMode, Union, Variant};
use crate::{ use crate::{
calc_fn_params_hash, combine_hashes, Dynamic, EvalAltResult, ExclusiveRange, Identifier, calc_fn_params_hash, combine_hashes, Dynamic, EvalAltResult, Identifier, ImmutableString,
ImmutableString, InclusiveRange, Module, Position, RhaiResult, Scope, Shared, StaticVec, INT, Module, Position, RhaiResult, Scope, Shared, StaticVec, INT,
}; };
#[cfg(feature = "no_std")] #[cfg(feature = "no_std")]
use std::prelude::v1::*; use std::prelude::v1::*;
@ -517,8 +517,10 @@ impl<'a> Target<'a> {
Self::LockGuard(_) => true, Self::LockGuard(_) => true,
Self::TempValue(_) => false, Self::TempValue(_) => false,
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, Self::Bit(_, _, _)
Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, | Self::BitField(_, _, _, _)
| Self::BlobByte(_, _, _)
| Self::StringChar(_, _, _) => false,
} }
} }
/// Is the `Target` a temp value? /// Is the `Target` a temp value?
@ -531,8 +533,10 @@ impl<'a> Target<'a> {
Self::LockGuard(_) => false, Self::LockGuard(_) => false,
Self::TempValue(_) => true, Self::TempValue(_) => true,
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, Self::Bit(_, _, _)
Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, | Self::BitField(_, _, _, _)
| Self::BlobByte(_, _, _)
| Self::StringChar(_, _, _) => false,
} }
} }
/// Is the `Target` a shared value? /// Is the `Target` a shared value?
@ -546,8 +550,10 @@ impl<'a> Target<'a> {
Self::LockGuard(_) => true, Self::LockGuard(_) => true,
Self::TempValue(r) => r.is_shared(), Self::TempValue(r) => r.is_shared(),
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Self::Bit(_, _, _) | Self::BitField(_, _, _, _) => false, Self::Bit(_, _, _)
Self::BlobByte(_, _, _) | Self::StringChar(_, _, _) => false, | Self::BitField(_, _, _, _)
| Self::BlobByte(_, _, _)
| Self::StringChar(_, _, _) => false,
} }
} }
/// Is the `Target` a specific type? /// Is the `Target` a specific type?
@ -729,8 +735,10 @@ impl Deref for Target<'_> {
Self::LockGuard((r, _)) => &**r, Self::LockGuard((r, _)) => &**r,
Self::TempValue(ref r) => r, Self::TempValue(ref r) => r,
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Self::Bit(_, ref r, _) | Self::BitField(_, _, ref r, _) => r, Self::Bit(_, ref r, _)
Self::BlobByte(_, _, ref r) | Self::StringChar(_, _, ref r) => r, | Self::BitField(_, _, ref r, _)
| Self::BlobByte(_, _, ref r)
| Self::StringChar(_, _, ref r) => r,
} }
} }
} }
@ -751,8 +759,10 @@ impl DerefMut for Target<'_> {
Self::LockGuard((r, _)) => r.deref_mut(), Self::LockGuard((r, _)) => r.deref_mut(),
Self::TempValue(ref mut r) => r, Self::TempValue(ref mut r) => r,
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Self::Bit(_, ref mut r, _) | Self::BitField(_, _, ref mut r, _) => r, Self::Bit(_, ref mut r, _)
Self::BlobByte(_, _, ref mut r) | Self::StringChar(_, _, ref mut r) => r, | Self::BitField(_, _, ref mut r, _)
| Self::BlobByte(_, _, ref mut r)
| Self::StringChar(_, _, ref mut r) => r,
} }
} }
} }
@ -2111,7 +2121,7 @@ impl Engine {
#[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_index"))]
Dynamic(Union::Int(value, _, _)) Dynamic(Union::Int(value, _, _))
if idx.is::<InclusiveRange>() || idx.is::<ExclusiveRange>() => if idx.is::<crate::ExclusiveRange>() || idx.is::<crate::InclusiveRange>() =>
{ {
#[cfg(not(feature = "only_i32"))] #[cfg(not(feature = "only_i32"))]
type BASE = u64; type BASE = u64;
@ -2121,7 +2131,7 @@ impl Engine {
// val_int[range] // val_int[range]
const BITS: usize = std::mem::size_of::<INT>() * 8; const BITS: usize = std::mem::size_of::<INT>() * 8;
let (shift, mask) = if let Some(range) = idx.read_lock::<ExclusiveRange>() { let (shift, mask) = if let Some(range) = idx.read_lock::<crate::ExclusiveRange>() {
let start = range.start; let start = range.start;
let end = range.end; let end = range.end;
@ -2141,7 +2151,7 @@ impl Engine {
(((2 as BASE).pow((end - start) as u32) - 1) as INT) << start, (((2 as BASE).pow((end - start) as u32) - 1) as INT) << start,
) )
} }
} else if let Some(range) = idx.read_lock::<InclusiveRange>() { } else if let Some(range) = idx.read_lock::<crate::InclusiveRange>() {
let start = *range.start(); let start = *range.start();
let end = *range.end(); let end = *range.end();

View File

@ -479,9 +479,12 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
lib.update_fn_metadata(_hash, &["string: &str", "Iterator<Item=char>"]); lib.update_fn_metadata(_hash, &["string: &str", "Iterator<Item=char>"]);
#[cfg(not(feature = "no_object"))]
{
let _hash = lib.set_getter_fn("chars", |string: &mut ImmutableString| Ok(CharsStream::new(string, 0, INT::MAX))); let _hash = lib.set_getter_fn("chars", |string: &mut ImmutableString| Ok(CharsStream::new(string, 0, INT::MAX)));
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
lib.update_fn_metadata(_hash, &["string: &mut ImmutableString", "Iterator<Item=char>"]); lib.update_fn_metadata(_hash, &["string: &mut ImmutableString", "Iterator<Item=char>"]);
}
// Register bit-field iterator // Register bit-field iterator
lib.set_iterator::<BitRange>(); lib.set_iterator::<BitRange>();
@ -514,9 +517,12 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
lib.update_fn_metadata(_hash, &["value: INT", "Iterator<Item=bool>"]); lib.update_fn_metadata(_hash, &["value: INT", "Iterator<Item=bool>"]);
#[cfg(not(feature = "no_object"))]
{
let _hash = lib.set_getter_fn("bits", |value: &mut INT| BitRange::new(*value, 0, INT::MAX) ); let _hash = lib.set_getter_fn("bits", |value: &mut INT| BitRange::new(*value, 0, INT::MAX) );
#[cfg(feature = "metadata")] #[cfg(feature = "metadata")]
lib.update_fn_metadata(_hash, &["value: &mut INT", "range: Range", "Iterator<Item=bool>"]); lib.update_fn_metadata(_hash, &["value: &mut INT", "range: Range", "Iterator<Item=bool>"]);
}
combine_with_exported_module!(lib, "range", range_functions); combine_with_exported_module!(lib, "range", range_functions);
}); });