Code cleanup and refactor.
This commit is contained in:
@@ -19,9 +19,21 @@ pub mod options;
|
||||
pub mod optimize;
|
||||
|
||||
pub mod limits;
|
||||
pub mod limits_unchecked;
|
||||
|
||||
pub mod events;
|
||||
|
||||
pub mod type_names;
|
||||
|
||||
pub mod custom_syntax;
|
||||
|
||||
pub mod build_type;
|
||||
|
||||
#[cfg(feature = "metadata")]
|
||||
pub mod definitions;
|
||||
|
||||
pub mod deprecated;
|
||||
|
||||
use crate::{Dynamic, Engine, Identifier};
|
||||
|
||||
#[cfg(feature = "no_std")]
|
||||
@@ -156,7 +168,7 @@ impl Engine {
|
||||
Some(token) if token.is_standard_keyword() => {
|
||||
if !self
|
||||
.disabled_symbols
|
||||
.as_ref()
|
||||
.as_deref()
|
||||
.map_or(false, |m| m.contains(token.literal_syntax()))
|
||||
{
|
||||
return Err(format!("'{keyword}' is a reserved keyword"));
|
||||
@@ -166,7 +178,7 @@ impl Engine {
|
||||
Some(token) if token.is_standard_symbol() => {
|
||||
if !self
|
||||
.disabled_symbols
|
||||
.as_ref()
|
||||
.as_deref()
|
||||
.map_or(false, |m| m.contains(token.literal_syntax()))
|
||||
{
|
||||
return Err(format!("'{keyword}' is a reserved operator"));
|
||||
@@ -176,7 +188,7 @@ impl Engine {
|
||||
Some(token)
|
||||
if !self
|
||||
.disabled_symbols
|
||||
.as_ref()
|
||||
.as_deref()
|
||||
.map_or(false, |m| m.contains(token.literal_syntax())) =>
|
||||
{
|
||||
return Err(format!("'{keyword}' is a reserved symbol"))
|
||||
@@ -212,82 +224,3 @@ impl Engine {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unchecked")]
|
||||
impl Engine {
|
||||
/// The maximum levels of function calls allowed for a script.
|
||||
///
|
||||
/// Always returns [`usize::MAX`] under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_call_levels(&self) -> usize {
|
||||
usize::MAX
|
||||
}
|
||||
/// The maximum number of operations allowed for a script to run (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_operations(&self) -> u64 {
|
||||
0
|
||||
}
|
||||
/// The maximum number of imported [modules][crate::Module] allowed for a script.
|
||||
///
|
||||
/// Always returns [`usize::MAX`] under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_modules(&self) -> usize {
|
||||
usize::MAX
|
||||
}
|
||||
/// The depth limit for expressions (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_expr_depth(&self) -> usize {
|
||||
0
|
||||
}
|
||||
/// The depth limit for expressions in functions (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_function_expr_depth(&self) -> usize {
|
||||
0
|
||||
}
|
||||
/// The maximum length of [strings][crate::ImmutableString] (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_string_size(&self) -> usize {
|
||||
0
|
||||
}
|
||||
/// The maximum length of [arrays][crate::Array] (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_array_size(&self) -> usize {
|
||||
0
|
||||
}
|
||||
/// The maximum size of [object maps][crate::Map] (0 for unlimited).
|
||||
///
|
||||
/// Always returns zero under `unchecked`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn max_map_size(&self) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
pub mod type_names;
|
||||
|
||||
pub mod custom_syntax;
|
||||
|
||||
pub mod build_type;
|
||||
|
||||
#[cfg(feature = "metadata")]
|
||||
pub mod definitions;
|
||||
|
||||
pub mod deprecated;
|
||||
|
Reference in New Issue
Block a user