Add allow_looping.

This commit is contained in:
Stephen Chung
2021-12-03 11:24:38 +08:00
parent 7cd76c6d18
commit fd26654125
4 changed files with 37 additions and 7 deletions

View File

@@ -16,6 +16,8 @@ pub struct LanguageOptions {
/// Is anonymous function allowed?
#[cfg(not(feature = "no_function"))]
pub allow_anonymous_fn: bool,
/// Is looping allowed?
pub allow_loop: bool,
}
impl LanguageOptions {
@@ -26,7 +28,9 @@ impl LanguageOptions {
allow_if_expr: true,
allow_switch_expr: true,
allow_stmt_expr: true,
#[cfg(not(feature = "no_function"))]
allow_anonymous_fn: true,
allow_loop: true,
}
}
}
@@ -84,4 +88,14 @@ impl Engine {
pub fn set_allow_anonymous_fn(&mut self, enable: bool) {
self.options.allow_anonymous_fn = enable;
}
/// Is looping allowed?
#[inline(always)]
pub fn allow_looping(&self) -> bool {
self.options.allow_loop
}
/// Set whether looping is allowed.
#[inline(always)]
pub fn set_allow_looping(&mut self, enable: bool) {
self.options.allow_loop = enable;
}
}