Add commands and status to debugging interface.
This commit is contained in:
@@ -905,11 +905,15 @@ impl Engine {
|
||||
Ok((
|
||||
if let Expr::Stack(slot, _) = arg_expr {
|
||||
#[cfg(feature = "debugging")]
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, arg_expr, level)?;
|
||||
if self.debugger.is_some() {
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, arg_expr, level)?;
|
||||
}
|
||||
constants[*slot].clone()
|
||||
} else if let Some(value) = arg_expr.get_literal_value() {
|
||||
#[cfg(feature = "debugging")]
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, arg_expr, level)?;
|
||||
if self.debugger.is_some() {
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, arg_expr, level)?;
|
||||
}
|
||||
value
|
||||
} else {
|
||||
self.eval_expr(scope, global, state, lib, this_ptr, arg_expr, level)?
|
||||
@@ -1155,7 +1159,9 @@ impl Engine {
|
||||
let first_expr = first_arg.unwrap();
|
||||
|
||||
#[cfg(feature = "debugging")]
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, first_expr, level)?;
|
||||
if self.debugger.is_some() {
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, first_expr, level)?;
|
||||
}
|
||||
|
||||
// func(x, ...) -> x.func(...)
|
||||
a_expr.iter().try_for_each(|expr| {
|
||||
@@ -1239,7 +1245,10 @@ impl Engine {
|
||||
// &mut first argument and avoid cloning the value
|
||||
if !args_expr.is_empty() && args_expr[0].is_variable_access(true) {
|
||||
#[cfg(feature = "debugging")]
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, &args_expr[0], level)?;
|
||||
if self.debugger.is_some() {
|
||||
let node = &args_expr[0];
|
||||
self.run_debugger(scope, global, state, lib, this_ptr, node, level)?;
|
||||
}
|
||||
|
||||
// func(x, ...) -> x.func(...)
|
||||
arg_values.push(Dynamic::UNIT);
|
||||
|
@@ -65,16 +65,16 @@ impl Engine {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
self.inc_operations(&mut global.num_operations, pos)?;
|
||||
|
||||
if fn_def.body.is_empty() {
|
||||
return Ok(Dynamic::UNIT);
|
||||
}
|
||||
|
||||
// Check for stack overflow
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if level > self.max_call_levels() {
|
||||
return Err(ERR::ErrorStackOverflow(pos).into());
|
||||
}
|
||||
|
||||
if fn_def.body.is_empty() {
|
||||
return Ok(Dynamic::UNIT);
|
||||
}
|
||||
|
||||
let orig_scope_len = scope.len();
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
let orig_imports_len = global.num_imports();
|
||||
@@ -133,7 +133,7 @@ impl Engine {
|
||||
};
|
||||
|
||||
// Evaluate the function
|
||||
let result = self
|
||||
let mut result = self
|
||||
.eval_stmt_block(
|
||||
scope,
|
||||
global,
|
||||
@@ -166,6 +166,31 @@ impl Engine {
|
||||
_ => make_error(fn_def.name.to_string(), fn_def, global, err, pos),
|
||||
});
|
||||
|
||||
#[cfg(feature = "debugging")]
|
||||
{
|
||||
if self.debugger.is_some() {
|
||||
match global.debugger.status() {
|
||||
crate::eval::DebuggerStatus::FunctionExit(n) if n >= level => {
|
||||
let node = crate::ast::Stmt::Noop(pos);
|
||||
let node = (&node).into();
|
||||
let event = match result {
|
||||
Ok(ref r) => crate::eval::DebuggerEvent::FunctionExitWithValue(r),
|
||||
Err(ref err) => crate::eval::DebuggerEvent::FunctionExitWithError(err),
|
||||
};
|
||||
if let Err(err) = self.run_debugger_raw(
|
||||
scope, global, state, lib, this_ptr, node, event, level,
|
||||
) {
|
||||
result = Err(err);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
// Pop the call stack
|
||||
global.debugger.rewind_call_stack(orig_call_stack_len);
|
||||
}
|
||||
|
||||
// Remove all local variables and imported modules
|
||||
if rewind_scope {
|
||||
scope.rewind(orig_scope_len);
|
||||
@@ -185,10 +210,6 @@ impl Engine {
|
||||
// Restore state
|
||||
state.rewind_fn_resolution_caches(orig_fn_resolution_caches_len);
|
||||
|
||||
// Pop the call stack
|
||||
#[cfg(feature = "debugging")]
|
||||
global.debugger.rewind_call_stack(orig_call_stack_len);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user