1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use crate::Engine;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct LanguageOptions {
pub allow_if_expr: bool,
pub allow_switch_expr: bool,
pub allow_stmt_expr: bool,
#[cfg(not(feature = "no_function"))]
pub allow_anonymous_fn: bool,
pub allow_loop: bool,
pub strict_var: bool,
}
impl LanguageOptions {
#[inline(always)]
pub const fn new() -> Self {
Self {
allow_if_expr: true,
allow_switch_expr: true,
allow_stmt_expr: true,
#[cfg(not(feature = "no_function"))]
allow_anonymous_fn: true,
allow_loop: true,
strict_var: false,
}
}
}
impl Default for LanguageOptions {
fn default() -> Self {
Self::new()
}
}
impl Engine {
#[inline(always)]
pub fn allow_if_expression(&self) -> bool {
self.options.allow_if_expr
}
#[inline(always)]
pub fn set_allow_if_expression(&mut self, enable: bool) {
self.options.allow_if_expr = enable;
}
#[inline(always)]
pub fn allow_switch_expression(&self) -> bool {
self.options.allow_switch_expr
}
#[inline(always)]
pub fn set_allow_switch_expression(&mut self, enable: bool) {
self.options.allow_switch_expr = enable;
}
#[inline(always)]
pub fn allow_statement_expression(&self) -> bool {
self.options.allow_stmt_expr
}
#[inline(always)]
pub fn set_allow_statement_expression(&mut self, enable: bool) {
self.options.allow_stmt_expr = enable;
}
#[cfg(not(feature = "no_function"))]
#[inline(always)]
pub fn allow_anonymous_fn(&self) -> bool {
self.options.allow_anonymous_fn
}
#[cfg(not(feature = "no_function"))]
#[inline(always)]
pub fn set_allow_anonymous_fn(&mut self, enable: bool) {
self.options.allow_anonymous_fn = enable;
}
#[inline(always)]
pub fn allow_looping(&self) -> bool {
self.options.allow_loop
}
#[inline(always)]
pub fn set_allow_looping(&mut self, enable: bool) {
self.options.allow_loop = enable;
}
#[inline(always)]
pub fn strict_variables(&self) -> bool {
self.options.strict_var
}
#[inline(always)]
pub fn set_strict_variables(&mut self, enable: bool) {
self.options.strict_var = enable;
}
}