Comments update.
This commit is contained in:
parent
dd8c18369b
commit
857ae7a64a
@ -187,7 +187,7 @@ impl Engine {
|
|||||||
///
|
///
|
||||||
/// # WARNING - Low Level API
|
/// # WARNING - Low Level API
|
||||||
///
|
///
|
||||||
/// This function is very low level.
|
/// This function is _extremely_ low level.
|
||||||
///
|
///
|
||||||
/// A [`GlobalRuntimeState`] and [`Caches`] need to be passed into the function, which can be
|
/// A [`GlobalRuntimeState`] and [`Caches`] need to be passed into the function, which can be
|
||||||
/// created via [`GlobalRuntimeState::new`] and [`Caches::new`].
|
/// created via [`GlobalRuntimeState::new`] and [`Caches::new`].
|
||||||
|
@ -17,8 +17,8 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// Not available under `no_module`.
|
/// Not available under `no_module`.
|
||||||
///
|
///
|
||||||
/// A [`u64`] offset to the current [stack of imported modules][crate::GlobalRuntimeState] is
|
/// A [`u64`] offset to the current stack of imported [modules][crate::Module] in the
|
||||||
/// cached for quick search purposes.
|
/// [global runtime state][crate::GlobalRuntimeState] is cached for quick search purposes.
|
||||||
///
|
///
|
||||||
/// A [`StaticVec`] is used because the vast majority of namespace-qualified access contains only
|
/// A [`StaticVec`] is used because the vast majority of namespace-qualified access contains only
|
||||||
/// one level, and it is wasteful to always allocate a [`Vec`] with one element.
|
/// one level, and it is wasteful to always allocate a [`Vec`] with one element.
|
||||||
|
@ -736,6 +736,42 @@ impl Engine {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Evaluate an argument.
|
||||||
|
#[inline]
|
||||||
|
pub(crate) fn get_arg_value(
|
||||||
|
&self,
|
||||||
|
scope: &mut Scope,
|
||||||
|
global: &mut GlobalRuntimeState,
|
||||||
|
caches: &mut Caches,
|
||||||
|
lib: &[&Module],
|
||||||
|
this_ptr: &mut Option<&mut Dynamic>,
|
||||||
|
arg_expr: &Expr,
|
||||||
|
level: usize,
|
||||||
|
) -> RhaiResultOf<(Dynamic, Position)> {
|
||||||
|
#[cfg(feature = "debugging")]
|
||||||
|
if self.debugger.is_some() {
|
||||||
|
if let Some(value) = arg_expr.get_literal_value() {
|
||||||
|
#[cfg(feature = "debugging")]
|
||||||
|
self.run_debugger(scope, global, lib, this_ptr, arg_expr, level)?;
|
||||||
|
return Ok((value, arg_expr.start_position()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not match function exit for arguments
|
||||||
|
#[cfg(feature = "debugging")]
|
||||||
|
let reset_debugger = global.debugger.clear_status_if(|status| {
|
||||||
|
matches!(status, crate::eval::DebuggerStatus::FunctionExit(..))
|
||||||
|
});
|
||||||
|
|
||||||
|
let result = self.eval_expr(scope, global, caches, lib, this_ptr, arg_expr, level);
|
||||||
|
|
||||||
|
// Restore function exit status
|
||||||
|
#[cfg(feature = "debugging")]
|
||||||
|
global.debugger.reset_status(reset_debugger);
|
||||||
|
|
||||||
|
Ok((result?, arg_expr.start_position()))
|
||||||
|
}
|
||||||
|
|
||||||
/// Call a dot method.
|
/// Call a dot method.
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
pub(crate) fn make_method_call(
|
pub(crate) fn make_method_call(
|
||||||
@ -892,42 +928,6 @@ impl Engine {
|
|||||||
Ok((result, updated))
|
Ok((result, updated))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate an argument.
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn get_arg_value(
|
|
||||||
&self,
|
|
||||||
scope: &mut Scope,
|
|
||||||
global: &mut GlobalRuntimeState,
|
|
||||||
caches: &mut Caches,
|
|
||||||
lib: &[&Module],
|
|
||||||
this_ptr: &mut Option<&mut Dynamic>,
|
|
||||||
arg_expr: &Expr,
|
|
||||||
level: usize,
|
|
||||||
) -> RhaiResultOf<(Dynamic, Position)> {
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
if self.debugger.is_some() {
|
|
||||||
if let Some(value) = arg_expr.get_literal_value() {
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
self.run_debugger(scope, global, lib, this_ptr, arg_expr, level)?;
|
|
||||||
return Ok((value, arg_expr.start_position()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not match function exit for arguments
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
let reset_debugger = global.debugger.clear_status_if(|status| {
|
|
||||||
matches!(status, crate::eval::DebuggerStatus::FunctionExit(..))
|
|
||||||
});
|
|
||||||
|
|
||||||
let result = self.eval_expr(scope, global, caches, lib, this_ptr, arg_expr, level);
|
|
||||||
|
|
||||||
// Restore function exit status
|
|
||||||
#[cfg(feature = "debugging")]
|
|
||||||
global.debugger.reset_status(reset_debugger);
|
|
||||||
|
|
||||||
Ok((result?, arg_expr.start_position()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call a function in normal function-call style.
|
/// Call a function in normal function-call style.
|
||||||
pub(crate) fn make_function_call(
|
pub(crate) fn make_function_call(
|
||||||
&self,
|
&self,
|
||||||
|
@ -387,6 +387,7 @@ fn match_token(input: &mut TokenStream, token: Token) -> (bool, Position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a variable name.
|
/// Parse a variable name.
|
||||||
|
#[inline]
|
||||||
fn parse_var_name(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
fn parse_var_name(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
||||||
match input.next().expect(NEVER_ENDS) {
|
match input.next().expect(NEVER_ENDS) {
|
||||||
// Variable name
|
// Variable name
|
||||||
@ -403,6 +404,7 @@ fn parse_var_name(input: &mut TokenStream) -> ParseResult<(SmartString, Position
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a symbol.
|
/// Parse a symbol.
|
||||||
|
#[inline]
|
||||||
fn parse_symbol(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
fn parse_symbol(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
||||||
match input.next().expect(NEVER_ENDS) {
|
match input.next().expect(NEVER_ENDS) {
|
||||||
// Symbol
|
// Symbol
|
||||||
@ -631,7 +633,7 @@ impl Engine {
|
|||||||
state: &mut ParseState,
|
state: &mut ParseState,
|
||||||
lib: &mut FnLib,
|
lib: &mut FnLib,
|
||||||
lhs: Expr,
|
lhs: Expr,
|
||||||
chained: bool,
|
check_index_type: bool,
|
||||||
settings: ParseSettings,
|
settings: ParseSettings,
|
||||||
) -> ParseResult<Expr> {
|
) -> ParseResult<Expr> {
|
||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
@ -644,7 +646,7 @@ impl Engine {
|
|||||||
// Check types of indexing that cannot be overridden
|
// Check types of indexing that cannot be overridden
|
||||||
// - arrays, maps, strings, bit-fields
|
// - arrays, maps, strings, bit-fields
|
||||||
match lhs {
|
match lhs {
|
||||||
_ if chained => (),
|
_ if !check_index_type => (),
|
||||||
|
|
||||||
Expr::Map(..) => match idx_expr {
|
Expr::Map(..) => match idx_expr {
|
||||||
// lhs[int]
|
// lhs[int]
|
||||||
@ -755,7 +757,7 @@ impl Engine {
|
|||||||
state,
|
state,
|
||||||
lib,
|
lib,
|
||||||
idx_expr,
|
idx_expr,
|
||||||
true,
|
false,
|
||||||
settings.level_up(),
|
settings.level_up(),
|
||||||
)?;
|
)?;
|
||||||
// Indexing binds to right
|
// Indexing binds to right
|
||||||
@ -1617,7 +1619,7 @@ impl Engine {
|
|||||||
// Indexing
|
// Indexing
|
||||||
#[cfg(not(feature = "no_index"))]
|
#[cfg(not(feature = "no_index"))]
|
||||||
(expr, Token::LeftBracket) => {
|
(expr, Token::LeftBracket) => {
|
||||||
self.parse_index_chain(input, state, lib, expr, false, settings.level_up())?
|
self.parse_index_chain(input, state, lib, expr, true, settings.level_up())?
|
||||||
}
|
}
|
||||||
// Property access
|
// Property access
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
@ -2704,15 +2706,16 @@ impl Engine {
|
|||||||
nesting_level: level,
|
nesting_level: level,
|
||||||
will_shadow,
|
will_shadow,
|
||||||
};
|
};
|
||||||
let context = EvalContext {
|
let mut this_ptr = None;
|
||||||
engine: self,
|
let context = EvalContext::new(
|
||||||
scope: &mut state.stack,
|
self,
|
||||||
global: &mut state.global,
|
&mut state.stack,
|
||||||
caches: None,
|
&mut state.global,
|
||||||
lib: &[],
|
None,
|
||||||
this_ptr: &mut None,
|
&[],
|
||||||
|
&mut this_ptr,
|
||||||
level,
|
level,
|
||||||
};
|
);
|
||||||
|
|
||||||
match filter(false, info, context) {
|
match filter(false, info, context) {
|
||||||
Ok(true) => (),
|
Ok(true) => (),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user