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).
|
* [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.
|
* 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.
|
* 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
|
For those who actually want their own language
|
||||||
|
@ -178,7 +178,7 @@ impl Engine {
|
|||||||
#[cfg(not(feature = "no_closure"))]
|
#[cfg(not(feature = "no_closure"))]
|
||||||
crate::func::call::ensure_no_data_race(name, &mut args, false)?;
|
crate::func::call::ensure_no_data_race(name, &mut args, false)?;
|
||||||
|
|
||||||
let result = self.call_script_fn(
|
self.call_script_fn(
|
||||||
scope,
|
scope,
|
||||||
global,
|
global,
|
||||||
state,
|
state,
|
||||||
@ -189,8 +189,6 @@ impl Engine {
|
|||||||
rewind_scope,
|
rewind_scope,
|
||||||
Position::NONE,
|
Position::NONE,
|
||||||
0,
|
0,
|
||||||
);
|
)
|
||||||
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,9 +227,9 @@ impl Engine {
|
|||||||
ast.as_ref(),
|
ast.as_ref(),
|
||||||
];
|
];
|
||||||
let lib = if lib.first().map(|m: &&Module| m.is_empty()).unwrap_or(true) {
|
let lib = if lib.first().map(|m: &&Module| m.is_empty()).unwrap_or(true) {
|
||||||
&lib[0..0]
|
&[]
|
||||||
} else {
|
} else {
|
||||||
&lib
|
&lib[..]
|
||||||
};
|
};
|
||||||
self.eval_global_statements(scope, global, &mut state, statements, lib, level)
|
self.eval_global_statements(scope, global, &mut state, statements, lib, level)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ impl EvalState<'_> {
|
|||||||
always_search_scope: false,
|
always_search_scope: false,
|
||||||
scope_level: 0,
|
scope_level: 0,
|
||||||
fn_resolution_caches: StaticVec::new_const(),
|
fn_resolution_caches: StaticVec::new_const(),
|
||||||
dummy: PhantomData::default(),
|
dummy: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Get the number of function resolution cache(s) in the stack.
|
/// 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::tokenizer::{Span, Token};
|
||||||
use crate::types::dynamic::AccessMode;
|
use crate::types::dynamic::AccessMode;
|
||||||
use crate::{
|
use crate::{
|
||||||
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnPtr, Position, Scope,
|
calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnPtr, Identifier,
|
||||||
StaticVec, AST, INT, INT_BITS,
|
Position, Scope, StaticVec, AST, INT, INT_BITS,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
@ -46,7 +46,7 @@ struct OptimizerState<'a> {
|
|||||||
/// Has the [`AST`] been changed during this pass?
|
/// Has the [`AST`] been changed during this pass?
|
||||||
changed: bool,
|
changed: bool,
|
||||||
/// Collection of constants to use for eager function evaluations.
|
/// Collection of constants to use for eager function evaluations.
|
||||||
variables: StaticVec<(String, AccessMode, Option<Dynamic>)>,
|
variables: StaticVec<(Identifier, AccessMode, Option<Dynamic>)>,
|
||||||
/// Activate constants propagation?
|
/// Activate constants propagation?
|
||||||
propagate_constants: bool,
|
propagate_constants: bool,
|
||||||
/// An [`Engine`] instance for eager function evaluation.
|
/// An [`Engine`] instance for eager function evaluation.
|
||||||
@ -100,7 +100,7 @@ impl<'a> OptimizerState<'a> {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn push_var(
|
pub fn push_var(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: impl Into<String>,
|
name: impl Into<Identifier>,
|
||||||
access: AccessMode,
|
access: AccessMode,
|
||||||
value: Option<Dynamic>,
|
value: Option<Dynamic>,
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user