Minor code restructure.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::GlobalRuntimeState;
|
||||
use crate::types::dynamic::Union;
|
||||
use crate::{Dynamic, Engine, Position, RhaiResultOf, ERR};
|
||||
use crate::{Dynamic, Engine, Position, RhaiResult, RhaiResultOf, ERR};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
@@ -150,4 +150,14 @@ impl Engine {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check a result to ensure that it is valid.
|
||||
#[inline]
|
||||
pub(crate) fn check_return_value(&self, result: RhaiResult, pos: Position) -> RhaiResult {
|
||||
if let Ok(ref r) = result {
|
||||
self.check_data_size(r, pos)?;
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
@@ -22,3 +22,36 @@ pub use eval_context::EvalContext;
|
||||
pub use global_state::GlobalConstants;
|
||||
pub use global_state::GlobalRuntimeState;
|
||||
pub use target::{calc_index, calc_offset_len, Target};
|
||||
|
||||
#[cfg(feature = "unchecked")]
|
||||
mod unchecked {
|
||||
use crate::{eval::GlobalRuntimeState, Dynamic, Engine, Position, RhaiResult, RhaiResultOf};
|
||||
|
||||
impl Engine {
|
||||
/// Check if the number of operations stay within limit.
|
||||
#[inline(always)]
|
||||
pub(crate) const fn track_operation(
|
||||
&self,
|
||||
_: &GlobalRuntimeState,
|
||||
_: Position,
|
||||
) -> RhaiResultOf<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check whether the size of a [`Dynamic`] is within limits.
|
||||
#[inline(always)]
|
||||
pub(crate) const fn check_data_size(&self, _: &Dynamic, _: Position) -> RhaiResultOf<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check a result to ensure that it is valid.
|
||||
#[inline(always)]
|
||||
pub(crate) const fn check_return_value(
|
||||
&self,
|
||||
result: RhaiResult,
|
||||
_: Position,
|
||||
) -> RhaiResult {
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user