Fix builds.

This commit is contained in:
Stephen Chung 2022-01-29 13:37:58 +08:00
parent 6b02dde848
commit 19ef92a3f3
6 changed files with 27 additions and 32 deletions

View File

@ -4,6 +4,8 @@ Rhai Release Notes
Version 1.5.0 Version 1.5.0
============= =============
This version adds a debugging interface, which can be used to integrate a debugger.
Bug fixes Bug fixes
--------- ---------

View File

@ -376,7 +376,11 @@ pub enum Expr {
Option<NonZeroU8>, Option<NonZeroU8>,
Position, Position,
#[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_module"))]
Box<(Option<NonZeroUsize>, Option<(crate::module::Namespace, u64)>, Identifier)>, Box<(
Option<NonZeroUsize>,
Option<(crate::module::Namespace, u64)>,
Identifier,
)>,
#[cfg(feature = "no_module")] Box<(Option<NonZeroUsize>, (), Identifier)>, #[cfg(feature = "no_module")] Box<(Option<NonZeroUsize>, (), Identifier)>,
), ),
/// Property access - ((getter, hash), (setter, hash), prop) /// Property access - ((getter, hash), (setter, hash), prop)

View File

@ -1,3 +1,5 @@
#![cfg(not(feature = "no_std"))]
#[cfg(feature = "debugging")] #[cfg(feature = "debugging")]
use rhai::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, Scope}; use rhai::{Dynamic, Engine, EvalAltResult, ImmutableString, Position, Scope};
@ -83,6 +85,7 @@ fn print_debug_help() {
println!("scope => print the scope"); println!("scope => print the scope");
println!("print => print all variables de-duplicated"); println!("print => print all variables de-duplicated");
println!("print <variable> => print the current value of a variable"); println!("print <variable> => print the current value of a variable");
#[cfg(not(feature = "no_module"))]
println!("imports => print all imported modules"); println!("imports => print all imported modules");
println!("node => print the current AST node"); println!("node => print the current AST node");
println!("backtrace => print the current call-stack"); println!("backtrace => print the current call-stack");
@ -162,8 +165,6 @@ fn main() {
let mut script = String::new(); let mut script = String::new();
let main_ast; let main_ast;
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_std"))]
{ {
// Load init scripts // Load init scripts
if let Some(filename) = env::args().skip(1).next() { if let Some(filename) = env::args().skip(1).next() {
@ -303,6 +304,7 @@ fn main() {
} }
} }
["print", ..] => print_scope(context.scope(), true), ["print", ..] => print_scope(context.scope(), true),
#[cfg(not(feature = "no_module"))]
["imports", ..] => { ["imports", ..] => {
for (i, (name, module)) in context for (i, (name, module)) in context
.global_runtime_state() .global_runtime_state()

View File

@ -62,7 +62,6 @@ impl<'x, 'px, 'm, 'pm, 'pt> EvalContext<'_, 'x, 'px, 'm, 'pm, '_, '_, '_, '_, 'p
/// _(internals)_ The current [`GlobalRuntimeState`]. /// _(internals)_ The current [`GlobalRuntimeState`].
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
#[cfg(feature = "internals")] #[cfg(feature = "internals")]
#[cfg(not(feature = "no_module"))]
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub const fn global_runtime_state(&self) -> &GlobalRuntimeState { pub const fn global_runtime_state(&self) -> &GlobalRuntimeState {
@ -71,7 +70,6 @@ impl<'x, 'px, 'm, 'pm, 'pt> EvalContext<'_, 'x, 'px, 'm, 'pm, '_, '_, '_, '_, 'p
/// _(internals)_ Get a mutable reference to the current [`GlobalRuntimeState`]. /// _(internals)_ Get a mutable reference to the current [`GlobalRuntimeState`].
/// Exported under the `internals` feature only. /// Exported under the `internals` feature only.
#[cfg(feature = "internals")] #[cfg(feature = "internals")]
#[cfg(not(feature = "no_module"))]
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
pub fn global_runtime_state_mut(&mut self) -> &mut &'m mut GlobalRuntimeState<'pm> { pub fn global_runtime_state_mut(&mut self) -> &mut &'m mut GlobalRuntimeState<'pm> {

View File

@ -580,21 +580,13 @@ impl Engine {
let func = self let func = self
.global_modules .global_modules
.iter() .iter()
.find_map(|m| m.get_iter(iter_type)) .find_map(|m| m.get_iter(iter_type));
.or_else(|| {
#[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_module"))]
return global.get_iter(iter_type); let func = func.or_else(|| global.get_iter(iter_type)).or_else(|| {
#[cfg(feature = "no_module")] self.global_sub_modules
return None;
})
.or_else(|| {
#[cfg(not(feature = "no_module"))]
return self
.global_sub_modules
.values() .values()
.find_map(|m| m.get_qualified_iter(iter_type)); .find_map(|m| m.get_qualified_iter(iter_type))
#[cfg(feature = "no_module")]
return None;
}); });
if let Some(func) = func { if let Some(func) = func {

View File

@ -241,31 +241,28 @@ impl Engine {
source: m.id_raw().clone(), source: m.id_raw().clone(),
}) })
}) })
}) });
.or_else(|| {
#[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_module"))]
return _global.get_qualified_fn(hash).map(|(func, source)| { let func = func
.or_else(|| {
_global.get_qualified_fn(hash).map(|(func, source)| {
FnResolutionCacheEntry { FnResolutionCacheEntry {
func: func.clone(), func: func.clone(),
source: source source: source
.map_or_else(|| Identifier::new_const(), Into::into), .map_or_else(|| Identifier::new_const(), Into::into),
} }
}); })
#[cfg(feature = "no_module")]
return None;
}) })
.or_else(|| { .or_else(|| {
#[cfg(not(feature = "no_module"))] self.global_sub_modules.values().find_map(|m| {
return self.global_sub_modules.values().find_map(|m| {
m.get_qualified_fn(hash).cloned().map(|func| { m.get_qualified_fn(hash).cloned().map(|func| {
FnResolutionCacheEntry { FnResolutionCacheEntry {
func, func,
source: m.id_raw().clone(), source: m.id_raw().clone(),
} }
}) })
}); })
#[cfg(feature = "no_module")]
return None;
}); });
match func { match func {