Move Engine default limits.
This commit is contained in:
parent
c7ec27acc7
commit
42638db0fb
@ -6,6 +6,34 @@ use std::num::{NonZeroU64, NonZeroUsize};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
pub mod defaults {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(debug_assertions)]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub const MAX_CALL_STACK_DEPTH: usize = 8;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(debug_assertions)]
|
||||
pub const MAX_EXPR_DEPTH: usize = 32;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(debug_assertions)]
|
||||
pub const MAX_FUNCTION_EXPR_DEPTH: usize = 16;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub const MAX_CALL_STACK_DEPTH: usize = 64;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const MAX_EXPR_DEPTH: usize = 64;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const MAX_FUNCTION_EXPR_DEPTH: usize = 32;
|
||||
|
||||
pub const MAX_DYNAMIC_PARAMETERS: usize = 16;
|
||||
}
|
||||
|
||||
/// A type containing all the limits imposed by the [`Engine`].
|
||||
///
|
||||
/// Not available under `unchecked`.
|
||||
@ -56,10 +84,10 @@ impl Limits {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
max_call_stack_depth: crate::engine::MAX_CALL_STACK_DEPTH,
|
||||
max_expr_depth: NonZeroUsize::new(crate::engine::MAX_EXPR_DEPTH),
|
||||
max_call_stack_depth: defaults::MAX_CALL_STACK_DEPTH,
|
||||
max_expr_depth: NonZeroUsize::new(defaults::MAX_EXPR_DEPTH),
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
max_function_expr_depth: NonZeroUsize::new(crate::engine::MAX_FUNCTION_EXPR_DEPTH),
|
||||
max_function_expr_depth: NonZeroUsize::new(defaults::MAX_FUNCTION_EXPR_DEPTH),
|
||||
max_operations: None,
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
max_modules: usize::MAX,
|
||||
|
@ -307,32 +307,6 @@ impl fmt::Debug for Imports {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(debug_assertions)]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub const MAX_CALL_STACK_DEPTH: usize = 8;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(debug_assertions)]
|
||||
pub const MAX_EXPR_DEPTH: usize = 32;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(debug_assertions)]
|
||||
pub const MAX_FUNCTION_EXPR_DEPTH: usize = 16;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub const MAX_CALL_STACK_DEPTH: usize = 64;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const MAX_EXPR_DEPTH: usize = 64;
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub const MAX_FUNCTION_EXPR_DEPTH: usize = 32;
|
||||
|
||||
pub const MAX_DYNAMIC_PARAMETERS: usize = 16;
|
||||
|
||||
pub const KEYWORD_PRINT: &str = "print";
|
||||
pub const KEYWORD_DEBUG: &str = "debug";
|
||||
pub const KEYWORD_TYPE_OF: &str = "type_of";
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
use super::native::{CallableFunction, FnAny};
|
||||
use super::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
||||
use crate::api::limits::defaults::MAX_DYNAMIC_PARAMETERS;
|
||||
use crate::ast::FnCallHashes;
|
||||
use crate::engine::{
|
||||
EvalState, FnResolutionCacheEntry, Imports, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR,
|
||||
KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_TYPE_OF,
|
||||
MAX_DYNAMIC_PARAMETERS,
|
||||
};
|
||||
use crate::module::NamespaceRef;
|
||||
use crate::tokenizer::Token;
|
||||
|
Loading…
Reference in New Issue
Block a user