Fix feature builds.
This commit is contained in:
parent
e918e61e95
commit
4fc088a0f1
@ -1,8 +1,12 @@
|
||||
//! Module that defines the `call_fn` API of [`Engine`].
|
||||
#![cfg(not(feature = "no_function"))]
|
||||
|
||||
use crate::engine::{EvalState, Imports};
|
||||
use crate::func::call::ensure_no_data_race;
|
||||
use crate::types::dynamic::Variant;
|
||||
use crate::{Dynamic, Engine, EvalAltResult, Position, RhaiResult, Scope, AST};
|
||||
use crate::{
|
||||
Dynamic, Engine, EvalAltResult, FuncArgs, Position, RhaiResult, Scope, StaticVec, AST,
|
||||
};
|
||||
use std::any::type_name;
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@ -50,16 +54,15 @@ impl Engine {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[inline]
|
||||
pub fn call_fn<T: Variant + Clone>(
|
||||
&self,
|
||||
scope: &mut Scope,
|
||||
ast: &AST,
|
||||
name: impl AsRef<str>,
|
||||
args: impl crate::FuncArgs,
|
||||
args: impl FuncArgs,
|
||||
) -> Result<T, Box<EvalAltResult>> {
|
||||
let mut arg_values = crate::StaticVec::new_const();
|
||||
let mut arg_values = StaticVec::new_const();
|
||||
args.parse(&mut arg_values);
|
||||
|
||||
let result = self.call_fn_raw(scope, ast, true, true, name, None, arg_values)?;
|
||||
@ -135,7 +138,6 @@ impl Engine {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[inline]
|
||||
pub fn call_fn_raw(
|
||||
&self,
|
||||
@ -165,7 +167,7 @@ impl Engine {
|
||||
let name = name.as_ref();
|
||||
let mut this_ptr = this_ptr;
|
||||
let mut arg_values = arg_values;
|
||||
let mut args: crate::StaticVec<_> = arg_values.as_mut().iter_mut().collect();
|
||||
let mut args: StaticVec<_> = arg_values.as_mut().iter_mut().collect();
|
||||
|
||||
let fn_def = ast
|
||||
.lib()
|
||||
@ -174,7 +176,7 @@ impl Engine {
|
||||
|
||||
// Check for data race.
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
crate::func::call::ensure_no_data_race(name, &mut args, false)?;
|
||||
ensure_no_data_race(name, &mut args, false)?;
|
||||
|
||||
let result = self.call_script_fn(
|
||||
scope,
|
||||
|
@ -6,15 +6,12 @@ pub mod run;
|
||||
|
||||
pub mod compile;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
|
||||
pub mod files;
|
||||
|
||||
pub mod register;
|
||||
|
||||
pub mod call_fn;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
pub mod limits;
|
||||
|
||||
pub mod events;
|
||||
|
@ -1,6 +1,5 @@
|
||||
//! Helper module which defines [`FuncArgs`] to make function calling easier.
|
||||
|
||||
#![cfg(not(feature = "no_function"))]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::types::dynamic::Variant;
|
||||
|
@ -1,17 +1,14 @@
|
||||
//! Module defining mechanisms to handle function calls in Rhai.
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub mod args;
|
||||
pub mod builtin;
|
||||
pub mod call;
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub mod func;
|
||||
pub mod hashing;
|
||||
pub mod native;
|
||||
pub mod plugin;
|
||||
pub mod register;
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use args::FuncArgs;
|
||||
pub use builtin::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
||||
pub use call::FnCallArgs;
|
||||
|
@ -75,7 +75,6 @@ mod custom_syntax;
|
||||
mod engine;
|
||||
mod func;
|
||||
mod module;
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
mod optimizer;
|
||||
pub mod packages;
|
||||
mod parser;
|
||||
@ -150,10 +149,10 @@ pub(crate) use func::{
|
||||
|
||||
pub use rhai_codegen::*;
|
||||
|
||||
pub use func::plugin;
|
||||
pub use func::{plugin, FuncArgs};
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use func::{Func, FuncArgs};
|
||||
pub use func::Func;
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use ast::ScriptFnMetadata;
|
||||
|
@ -1,8 +1,9 @@
|
||||
#![cfg(not(feature = "no_std"))]
|
||||
#![cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
|
||||
|
||||
use crate::func::native::shared_write_lock;
|
||||
use crate::{Engine, EvalAltResult, Identifier, Module, ModuleResolver, Position, Scope, Shared};
|
||||
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
io::Error as IoError,
|
||||
|
@ -9,8 +9,6 @@ pub use dummy::DummyModuleResolver;
|
||||
mod collection;
|
||||
pub use collection::ModuleResolversCollection;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
|
||||
mod file;
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
|
@ -1,16 +1,18 @@
|
||||
//! Module implementing the [`AST`] optimizer.
|
||||
#![cfg(not(feature = "no_optimize"))]
|
||||
|
||||
use crate::ast::{Expr, OpAssignment, Stmt, AST_OPTION_FLAGS::*};
|
||||
use crate::ast::{Expr, OpAssignment, ScriptFnDef, Stmt, StmtBlock, AST_OPTION_FLAGS::*};
|
||||
use crate::engine::{
|
||||
EvalState, Imports, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR, KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
||||
};
|
||||
use crate::func::builtin::get_builtin_binary_op_fn;
|
||||
use crate::func::hashing::get_hasher;
|
||||
use crate::func::native::shared_take_or_clone;
|
||||
use crate::tokenizer::Token;
|
||||
use crate::types::dynamic::AccessMode;
|
||||
use crate::{
|
||||
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnPtr, ImmutableString,
|
||||
Module, Position, Scope, StaticVec, AST,
|
||||
Module, Position, Scope, Shared, StaticVec, AST,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@ -1122,7 +1124,7 @@ pub fn optimize_into_ast(
|
||||
engine: &Engine,
|
||||
scope: &Scope,
|
||||
statements: StaticVec<Stmt>,
|
||||
functions: StaticVec<crate::Shared<crate::ast::ScriptFnDef>>,
|
||||
functions: StaticVec<Shared<ScriptFnDef>>,
|
||||
optimization_level: OptimizationLevel,
|
||||
) -> AST {
|
||||
let level = if cfg!(feature = "no_optimize") {
|
||||
@ -1144,14 +1146,14 @@ pub fn optimize_into_ast(
|
||||
|
||||
_functions
|
||||
.iter()
|
||||
.map(|fn_def| crate::ast::ScriptFnDef {
|
||||
.map(|fn_def| ScriptFnDef {
|
||||
name: fn_def.name.clone(),
|
||||
access: fn_def.access,
|
||||
body: crate::ast::StmtBlock::NONE,
|
||||
body: StmtBlock::NONE,
|
||||
params: fn_def.params.clone(),
|
||||
lib: None,
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
mods: crate::engine::Imports::new(),
|
||||
mods: Imports::new(),
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(feature = "metadata")]
|
||||
comments: None,
|
||||
@ -1165,7 +1167,7 @@ pub fn optimize_into_ast(
|
||||
_functions
|
||||
.into_iter()
|
||||
.map(|fn_def| {
|
||||
let mut fn_def = crate::func::native::shared_take_or_clone(fn_def);
|
||||
let mut fn_def = shared_take_or_clone(fn_def);
|
||||
|
||||
// Optimize the function body
|
||||
let body = mem::take(fn_def.body.deref_mut());
|
||||
|
@ -3,22 +3,18 @@
|
||||
use crate::{Module, Shared};
|
||||
|
||||
pub(crate) mod arithmetic;
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
mod array_basic;
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
mod blob_basic;
|
||||
mod fn_basic;
|
||||
mod iter_basic;
|
||||
mod lang_core;
|
||||
mod logic;
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
mod map_basic;
|
||||
mod math_basic;
|
||||
mod pkg_core;
|
||||
mod pkg_std;
|
||||
mod string_basic;
|
||||
mod string_more;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
mod time_basic;
|
||||
|
||||
pub use arithmetic::ArithmeticPackage;
|
||||
|
@ -3,8 +3,6 @@
|
||||
use super::{arithmetic::make_err as make_arithmetic_err, math_basic::MAX_INT};
|
||||
use crate::plugin::*;
|
||||
use crate::{def_package, Dynamic, EvalAltResult, INT};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use crate::FLOAT;
|
||||
|
Loading…
Reference in New Issue
Block a user