Fix builds.

This commit is contained in:
Stephen Chung 2022-11-08 21:41:00 +08:00
parent e93923b3b6
commit ae1e19c98a
4 changed files with 11 additions and 21 deletions

View File

@ -3,7 +3,6 @@
use crate::eval::{Caches, GlobalRuntimeState}; use crate::eval::{Caches, GlobalRuntimeState};
use crate::types::dynamic::Variant; use crate::types::dynamic::Variant;
use crate::types::RestoreOnDrop;
use crate::{ use crate::{
reify, Dynamic, Engine, FuncArgs, Position, RhaiResult, RhaiResultOf, Scope, SharedModule, reify, Dynamic, Engine, FuncArgs, Position, RhaiResult, RhaiResultOf, Scope, SharedModule,
StaticVec, AST, ERR, StaticVec, AST, ERR,
@ -252,7 +251,7 @@ impl Engine {
let lib = &[AsRef::<SharedModule>::as_ref(ast).clone()]; let lib = &[AsRef::<SharedModule>::as_ref(ast).clone()];
let mut no_this_ptr = Dynamic::NULL; let mut no_this_ptr = Dynamic::NULL;
let mut this_ptr = this_ptr.unwrap_or(&mut no_this_ptr); let this_ptr = this_ptr.unwrap_or(&mut no_this_ptr);
let orig_scope_len = scope.len(); let orig_scope_len = scope.len();
@ -262,7 +261,7 @@ impl Engine {
ast.resolver().cloned(), ast.resolver().cloned(),
); );
#[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_module"))]
let global = &mut *RestoreOnDrop::lock(global, move |g| { let global = &mut *crate::types::RestoreOnDrop::lock(global, move |g| {
g.embedded_module_resolver = orig_embedded_module_resolver g.embedded_module_resolver = orig_embedded_module_resolver
}); });
@ -278,11 +277,11 @@ impl Engine {
Ok(Dynamic::UNIT) Ok(Dynamic::UNIT)
} }
.and_then(|_| { .and_then(|_| {
let mut args: StaticVec<_> = arg_values.iter_mut().collect(); let args = &mut arg_values.iter_mut().collect::<StaticVec<_>>();
// Check for data race. // Check for data race.
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
crate::func::ensure_no_data_race(name, &args, false).map(|_| Dynamic::UNIT)?; crate::func::ensure_no_data_race(name, args, false).map(|_| Dynamic::UNIT)?;
if let Some(fn_def) = ast.shared_lib().get_script_fn(name, args.len()) { if let Some(fn_def) = ast.shared_lib().get_script_fn(name, args.len()) {
self.call_script_fn( self.call_script_fn(
@ -290,9 +289,9 @@ impl Engine {
caches, caches,
lib, lib,
scope, scope,
&mut this_ptr, this_ptr,
fn_def, fn_def,
&mut args, args,
rewind_scope, rewind_scope,
Position::NONE, Position::NONE,
) )
@ -305,7 +304,7 @@ impl Engine {
if self.debugger.is_some() { if self.debugger.is_some() {
global.debugger.status = crate::eval::DebuggerStatus::Terminate; global.debugger.status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(Position::NONE); let node = &crate::ast::Stmt::Noop(Position::NONE);
self.run_debugger(global, caches, lib, scope, &mut this_ptr, node)?; self.run_debugger(global, caches, lib, scope, this_ptr, node)?;
} }
Ok(result) Ok(result)

View File

@ -3,7 +3,6 @@
use crate::eval::{Caches, GlobalRuntimeState}; use crate::eval::{Caches, GlobalRuntimeState};
use crate::parser::ParseState; use crate::parser::ParseState;
use crate::types::dynamic::Variant; use crate::types::dynamic::Variant;
use crate::types::RestoreOnDrop;
use crate::{ use crate::{
Dynamic, Engine, OptimizationLevel, Position, RhaiResult, RhaiResultOf, Scope, AST, ERR, Dynamic, Engine, OptimizationLevel, Position, RhaiResult, RhaiResultOf, Scope, AST, ERR,
}; };
@ -229,7 +228,7 @@ impl Engine {
ast.resolver().cloned(), ast.resolver().cloned(),
); );
#[cfg(not(feature = "no_module"))] #[cfg(not(feature = "no_module"))]
let global = &mut *RestoreOnDrop::lock(global, move |g| { let global = &mut *crate::types::RestoreOnDrop::lock(global, move |g| {
g.embedded_module_resolver = orig_embedded_module_resolver g.embedded_module_resolver = orig_embedded_module_resolver
}); });

View File

@ -730,12 +730,11 @@ impl Engine {
// Check variable definition filter // Check variable definition filter
if let Some(ref filter) = self.def_var_filter { if let Some(ref filter) = self.def_var_filter {
let will_shadow = scope.contains(var_name); let will_shadow = scope.contains(var_name);
let nesting_level = global.scope_level;
let is_const = access == AccessMode::ReadOnly; let is_const = access == AccessMode::ReadOnly;
let info = VarDefInfo { let info = VarDefInfo {
name: var_name, name: var_name,
is_const, is_const,
nesting_level, nesting_level: global.scope_level,
will_shadow, will_shadow,
}; };
let context = EvalContext::new(self, global, caches, lib, scope, this_ptr); let context = EvalContext::new(self, global, caches, lib, scope, this_ptr);

View File

@ -161,16 +161,9 @@ impl FnPtr {
&lib &lib
}; };
let global = &mut GlobalRuntimeState::new(engine); let global = &GlobalRuntimeState::new(engine);
let ctx = NativeCallContext::new_with_all_fields( let ctx = (engine, self.fn_name(), None, global, lib, Position::NONE).into();
engine,
self.fn_name(),
None,
global,
lib,
Position::NONE,
);
let result = self.call_raw(&ctx, None, arg_values)?; let result = self.call_raw(&ctx, None, arg_values)?;