Add eval_expression_tree_raw.

This commit is contained in:
Stephen Chung
2022-07-06 12:56:15 +08:00
parent b4dbc7619a
commit dda7bc7b85
7 changed files with 104 additions and 12 deletions

View File

@@ -185,6 +185,10 @@ impl Engine {
///
/// Not available under `no_function`.
///
/// # WARNING - Unstable API
///
/// This API is volatile and may change in the future.
///
/// # WARNING - Low Level API
///
/// This function is _extremely_ low level.
@@ -202,6 +206,7 @@ impl Engine {
/// Do not use the arguments after this call. If they are needed afterwards, clone them _before_
/// calling this function.
#[cfg(feature = "internals")]
#[deprecated = "This API is NOT deprecated, but it is considered volatile and may change in the future."]
#[inline(always)]
pub fn call_fn_raw_raw(
&self,

View File

@@ -74,6 +74,28 @@ impl Expression<'_> {
pub fn eval_with_context(&self, context: &mut EvalContext) -> RhaiResult {
context.eval_expression_tree(self)
}
/// Evaluate this [expression tree][Expression] within an [evaluation context][`EvalContext`].
///
/// The following option is available:
///
/// * whether to rewind the [`Scope`] after evaluation if the expression is a [`StmtBlock`][crate::ast::StmtBlock]
///
/// # WARNING - Unstable API
///
/// This API is volatile and may change in the future.
///
/// # WARNING - Low Level API
///
/// This function is _extremely_ low level. It evaluates an expression from an [`AST`][crate::AST].
#[inline(always)]
pub fn eval_with_context_raw(
&self,
context: &mut EvalContext,
rewind_scope: bool,
) -> RhaiResult {
#[allow(deprecated)]
context.eval_expression_tree_raw(self, rewind_scope)
}
/// Get the value of this expression if it is a variable name or a string constant.
///
/// Returns [`None`] also if the constant is not of the specified type.