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")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
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`].
|
/// A type containing all the limits imposed by the [`Engine`].
|
||||||
///
|
///
|
||||||
/// Not available under `unchecked`.
|
/// Not available under `unchecked`.
|
||||||
@ -56,10 +84,10 @@ impl Limits {
|
|||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
max_call_stack_depth: crate::engine::MAX_CALL_STACK_DEPTH,
|
max_call_stack_depth: defaults::MAX_CALL_STACK_DEPTH,
|
||||||
max_expr_depth: NonZeroUsize::new(crate::engine::MAX_EXPR_DEPTH),
|
max_expr_depth: NonZeroUsize::new(defaults::MAX_EXPR_DEPTH),
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[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,
|
max_operations: None,
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
max_modules: usize::MAX,
|
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_PRINT: &str = "print";
|
||||||
pub const KEYWORD_DEBUG: &str = "debug";
|
pub const KEYWORD_DEBUG: &str = "debug";
|
||||||
pub const KEYWORD_TYPE_OF: &str = "type_of";
|
pub const KEYWORD_TYPE_OF: &str = "type_of";
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
use super::native::{CallableFunction, FnAny};
|
use super::native::{CallableFunction, FnAny};
|
||||||
use super::{get_builtin_binary_op_fn, get_builtin_op_assignment_fn};
|
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::ast::FnCallHashes;
|
||||||
use crate::engine::{
|
use crate::engine::{
|
||||||
EvalState, FnResolutionCacheEntry, Imports, KEYWORD_DEBUG, KEYWORD_EVAL, KEYWORD_FN_PTR,
|
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,
|
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::module::NamespaceRef;
|
||||||
use crate::tokenizer::Token;
|
use crate::tokenizer::Token;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user