Support call stack and FunctionExit for native functions.

This commit is contained in:
Stephen Chung
2022-02-02 14:47:35 +08:00
parent 7163a7331a
commit 4a80483749
13 changed files with 190 additions and 77 deletions

View File

@@ -120,6 +120,7 @@ impl Engine {
target: &mut Target,
root: (&str, Position),
new_val: Dynamic,
level: usize,
) -> RhaiResultOf<()> {
if target.is_read_only() {
// Assignment to constant variable
@@ -154,7 +155,7 @@ impl Engine {
let args = &mut [lhs_ptr_inner, &mut new_val];
match self.call_native_fn(
global, state, lib, op_assign, hash, args, true, true, op_pos,
global, state, lib, op_assign, hash, args, true, true, op_pos, level,
) {
Ok(_) => {
#[cfg(not(feature = "unchecked"))]
@@ -164,7 +165,7 @@ impl Engine {
{
// Expand to `var = var op rhs`
let (value, _) = self.call_native_fn(
global, state, lib, op, hash_op, args, true, false, op_pos,
global, state, lib, op, hash_op, args, true, false, op_pos, level,
)?;
#[cfg(not(feature = "unchecked"))]
@@ -266,6 +267,7 @@ impl Engine {
&mut lhs_ptr,
(var_name, pos),
rhs_val,
level,
)
.map_err(|err| err.fill_position(rhs.position()))
.map(|_| Dynamic::UNIT)