Fix builds.

This commit is contained in:
Stephen Chung 2022-01-28 21:35:16 +08:00
parent 66af69aaff
commit c93e94c7cd
3 changed files with 12 additions and 4 deletions

View File

@ -57,6 +57,8 @@ impl GlobalRuntimeState<'_> {
#[inline(always)]
#[must_use]
pub fn new(engine: &Engine) -> Self {
let _engine = engine;
Self {
keys: StaticVec::new_const(),
modules: StaticVec::new_const(),
@ -71,7 +73,7 @@ impl GlobalRuntimeState<'_> {
#[cfg(not(feature = "no_function"))]
constants: std::collections::BTreeMap::new().into(),
#[cfg(feature = "debugging")]
debugger: crate::eval::Debugger::new(engine),
debugger: crate::eval::Debugger::new(_engine),
dummy: PhantomData::default(),
}
}

View File

@ -1685,6 +1685,8 @@ impl Module {
// Save global state
let orig_imports_len = global.num_imports();
let orig_source = global.source.clone();
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_function"))]
let orig_constants = std::mem::take(&mut global.constants);
// Run the script
@ -1717,7 +1719,11 @@ impl Module {
}
// Restore global state
global.constants = orig_constants;
#[cfg(not(feature = "no_module"))]
#[cfg(not(feature = "no_function"))]
{
global.constants = orig_constants;
}
global.truncate_imports(orig_imports_len);
global.source = orig_source;

View File

@ -4,7 +4,7 @@ use crate::api::custom_syntax::{markers::*, CustomSyntax};
use crate::api::options::LanguageOptions;
use crate::ast::{
BinaryExpr, ConditionalStmtBlock, CustomExpr, Expr, FnCallExpr, FnCallHashes, Ident,
OpAssignment, ScriptFnDef, Stmt, StmtBlock, SwitchCases, TryCatchBlock, AST_OPTION_FLAGS::*,
OpAssignment, ScriptFnDef, Stmt, SwitchCases, TryCatchBlock, AST_OPTION_FLAGS::*,
};
use crate::engine::{Precedence, KEYWORD_THIS, OP_CONTAINS};
use crate::func::hashing::get_hasher;
@ -3184,7 +3184,7 @@ fn make_curry_from_externals(
let mut statements = StaticVec::with_capacity(externals.len() + 1);
statements.extend(externals.into_iter().map(Stmt::Share));
statements.push(Stmt::Expr(expr));
Expr::Stmt(StmtBlock::new(statements, pos).into())
Expr::Stmt(crate::ast::StmtBlock::new(statements, pos).into())
}
/// Parse an anonymous function definition.