Pass level to var resolver.
This commit is contained in:
parent
5aee06674f
commit
936dc01e39
@ -673,7 +673,7 @@ impl Engine {
|
|||||||
self.inc_operations(&mut global.num_operations, *var_pos)?;
|
self.inc_operations(&mut global.num_operations, *var_pos)?;
|
||||||
|
|
||||||
let (mut target, _) =
|
let (mut target, _) =
|
||||||
self.search_namespace(scope, global, state, lib, this_ptr, lhs)?;
|
self.search_namespace(scope, global, state, lib, this_ptr, lhs, level)?;
|
||||||
|
|
||||||
let obj_ptr = &mut target;
|
let obj_ptr = &mut target;
|
||||||
let root = (x.2.as_str(), *var_pos);
|
let root = (x.2.as_str(), *var_pos);
|
||||||
|
@ -50,15 +50,18 @@ impl Engine {
|
|||||||
lib: &[&Module],
|
lib: &[&Module],
|
||||||
this_ptr: &'s mut Option<&mut Dynamic>,
|
this_ptr: &'s mut Option<&mut Dynamic>,
|
||||||
expr: &Expr,
|
expr: &Expr,
|
||||||
|
level: usize,
|
||||||
) -> RhaiResultOf<(Target<'s>, Position)> {
|
) -> RhaiResultOf<(Target<'s>, Position)> {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::Variable(Some(_), _, _) => {
|
Expr::Variable(Some(_), _, _) => {
|
||||||
self.search_scope_only(scope, global, state, lib, this_ptr, expr)
|
self.search_scope_only(scope, global, state, lib, this_ptr, expr, level)
|
||||||
}
|
}
|
||||||
Expr::Variable(None, _var_pos, v) => match v.as_ref() {
|
Expr::Variable(None, _var_pos, v) => match v.as_ref() {
|
||||||
// Normal variable access
|
// Normal variable access
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
(_, None, _) => self.search_scope_only(scope, global, state, lib, this_ptr, expr),
|
(_, None, _) => {
|
||||||
|
self.search_scope_only(scope, global, state, lib, this_ptr, expr, level)
|
||||||
|
}
|
||||||
#[cfg(feature = "no_module")]
|
#[cfg(feature = "no_module")]
|
||||||
(_, (), _) => self.search_scope_only(scope, global, state, lib, this_ptr, expr),
|
(_, (), _) => self.search_scope_only(scope, global, state, lib, this_ptr, expr),
|
||||||
|
|
||||||
@ -136,6 +139,7 @@ impl Engine {
|
|||||||
lib: &[&Module],
|
lib: &[&Module],
|
||||||
this_ptr: &'s mut Option<&mut Dynamic>,
|
this_ptr: &'s mut Option<&mut Dynamic>,
|
||||||
expr: &Expr,
|
expr: &Expr,
|
||||||
|
level: usize,
|
||||||
) -> RhaiResultOf<(Target<'s>, Position)> {
|
) -> RhaiResultOf<(Target<'s>, Position)> {
|
||||||
// Make sure that the pointer indirection is taken only when absolutely necessary.
|
// Make sure that the pointer indirection is taken only when absolutely necessary.
|
||||||
|
|
||||||
@ -163,7 +167,7 @@ impl Engine {
|
|||||||
state,
|
state,
|
||||||
lib,
|
lib,
|
||||||
this_ptr,
|
this_ptr,
|
||||||
level: 0,
|
level,
|
||||||
};
|
};
|
||||||
match resolve_var(
|
match resolve_var(
|
||||||
expr.get_variable_name(true).expect("`Expr::Variable`"),
|
expr.get_variable_name(true).expect("`Expr::Variable`"),
|
||||||
@ -297,7 +301,7 @@ impl Engine {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.ok_or_else(|| ERR::ErrorUnboundThis(*var_pos).into())
|
.ok_or_else(|| ERR::ErrorUnboundThis(*var_pos).into())
|
||||||
} else {
|
} else {
|
||||||
self.search_namespace(scope, global, state, lib, this_ptr, expr)
|
self.search_namespace(scope, global, state, lib, this_ptr, expr, level)
|
||||||
.map(|(val, _)| val.take_or_clone())
|
.map(|(val, _)| val.take_or_clone())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1230,7 +1230,7 @@ impl Engine {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let (mut target, _pos) =
|
let (mut target, _pos) =
|
||||||
self.search_namespace(scope, global, state, lib, this_ptr, first_expr)?;
|
self.search_namespace(scope, global, state, lib, this_ptr, first_expr, level)?;
|
||||||
|
|
||||||
if target.as_ref().is_read_only() {
|
if target.as_ref().is_read_only() {
|
||||||
target = target.into_owned();
|
target = target.into_owned();
|
||||||
@ -1316,8 +1316,9 @@ impl Engine {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Get target reference to first argument
|
// Get target reference to first argument
|
||||||
|
let first_arg = &args_expr[0];
|
||||||
let (target, _pos) =
|
let (target, _pos) =
|
||||||
self.search_scope_only(scope, global, state, lib, this_ptr, &args_expr[0])?;
|
self.search_scope_only(scope, global, state, lib, this_ptr, first_arg, level)?;
|
||||||
|
|
||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
self.inc_operations(&mut global.num_operations, _pos)?;
|
self.inc_operations(&mut global.num_operations, _pos)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user