Rename Imports to GlobalRuntimeState.

This commit is contained in:
Stephen Chung
2021-12-27 23:03:30 +08:00
parent e8b070cbf8
commit a78488d935
13 changed files with 373 additions and 342 deletions

View File

@@ -1,7 +1,7 @@
//! Module that defines the `call_fn` API of [`Engine`].
#![cfg(not(feature = "no_function"))]
use crate::engine::{EvalState, Imports};
use crate::engine::{EvalState, GlobalRuntimeState};
use crate::types::dynamic::Variant;
use crate::{
Dynamic, Engine, FuncArgs, Position, RhaiResult, RhaiResultOf, Scope, StaticVec, AST, ERR,
@@ -154,13 +154,13 @@ impl Engine {
arg_values: impl AsMut<[Dynamic]>,
) -> RhaiResult {
let state = &mut EvalState::new();
let mods = &mut Imports::new();
let global = &mut GlobalRuntimeState::new();
let statements = ast.statements();
let orig_scope_len = scope.len();
if eval_ast && !statements.is_empty() {
self.eval_global_statements(scope, mods, state, statements, &[ast.as_ref()], 0)?;
self.eval_global_statements(scope, global, state, statements, &[ast.as_ref()], 0)?;
if rewind_scope {
scope.rewind(orig_scope_len);
@@ -183,7 +183,7 @@ impl Engine {
let result = self.call_script_fn(
scope,
mods,
global,
state,
&[ast.as_ref()],
&mut this_ptr,