Minor refactor.
This commit is contained in:
parent
5caf20d26b
commit
6369fa5c65
@ -61,6 +61,7 @@ Protected against attacks
|
||||
* [Sand-boxed](https://rhai.rs/book/safety/sandbox.html) - the scripting engine, if declared immutable, cannot mutate the containing environment unless [explicitly permitted](https://rhai.rs/book/patterns/control.html).
|
||||
* Rugged - protected against malicious attacks (such as [stack-overflow](https://rhai.rs/book/safety/max-call-stack.html), [over-sized data](https://rhai.rs/book/safety/max-string-size.html), and [runaway scripts](https://rhai.rs/book/safety/max-operations.html) etc.) that may come from untrusted third-party user-land scripts.
|
||||
* Track script evaluation [progress](https://rhai.rs/book/safety/progress.html) and manually terminate a script run.
|
||||
* Passes Miri.
|
||||
|
||||
|
||||
For those who actually want their own language
|
||||
|
@ -178,7 +178,7 @@ impl Engine {
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
crate::func::call::ensure_no_data_race(name, &mut args, false)?;
|
||||
|
||||
let result = self.call_script_fn(
|
||||
self.call_script_fn(
|
||||
scope,
|
||||
global,
|
||||
state,
|
||||
@ -189,8 +189,6 @@ impl Engine {
|
||||
rewind_scope,
|
||||
Position::NONE,
|
||||
0,
|
||||
);
|
||||
|
||||
result
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -227,9 +227,9 @@ impl Engine {
|
||||
ast.as_ref(),
|
||||
];
|
||||
let lib = if lib.first().map(|m: &&Module| m.is_empty()).unwrap_or(true) {
|
||||
&lib[0..0]
|
||||
&[]
|
||||
} else {
|
||||
&lib
|
||||
&lib[..]
|
||||
};
|
||||
self.eval_global_statements(scope, global, &mut state, statements, lib, level)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ impl EvalState<'_> {
|
||||
always_search_scope: false,
|
||||
scope_level: 0,
|
||||
fn_resolution_caches: StaticVec::new_const(),
|
||||
dummy: PhantomData::default(),
|
||||
dummy: Default::default(),
|
||||
}
|
||||
}
|
||||
/// Get the number of function resolution cache(s) in the stack.
|
||||
|
@ -9,8 +9,8 @@ use crate::func::hashing::get_hasher;
|
||||
use crate::tokenizer::{Span, Token};
|
||||
use crate::types::dynamic::AccessMode;
|
||||
use crate::{
|
||||
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnPtr, Position, Scope,
|
||||
StaticVec, AST, INT, INT_BITS,
|
||||
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnPtr, Identifier,
|
||||
Position, Scope, StaticVec, AST, INT, INT_BITS,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@ -46,7 +46,7 @@ struct OptimizerState<'a> {
|
||||
/// Has the [`AST`] been changed during this pass?
|
||||
changed: bool,
|
||||
/// Collection of constants to use for eager function evaluations.
|
||||
variables: StaticVec<(String, AccessMode, Option<Dynamic>)>,
|
||||
variables: StaticVec<(Identifier, AccessMode, Option<Dynamic>)>,
|
||||
/// Activate constants propagation?
|
||||
propagate_constants: bool,
|
||||
/// An [`Engine`] instance for eager function evaluation.
|
||||
@ -100,7 +100,7 @@ impl<'a> OptimizerState<'a> {
|
||||
#[inline(always)]
|
||||
pub fn push_var(
|
||||
&mut self,
|
||||
name: impl Into<String>,
|
||||
name: impl Into<Identifier>,
|
||||
access: AccessMode,
|
||||
value: Option<Dynamic>,
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user