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
=============
This version adds a debugging interface, which can be used to integrate a debugger.
Bug fixes
---------

View File

@ -376,7 +376,11 @@ pub enum Expr {
Option<NonZeroU8>,
Position,
#[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)>,
),
/// Property access - ((getter, hash), (setter, hash), prop)

View File

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

View File

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

View File

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