From db2f1a601c213ba9fc775b126194ea041c3f174e Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 2 Feb 2022 15:07:22 +0800 Subject: [PATCH] Make call stack available also under no_function. --- src/eval/debugger.rs | 15 +-------------- src/eval/mod.rs | 7 ++----- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/eval/debugger.rs b/src/eval/debugger.rs index d2d2234d..d8a29d9e 100644 --- a/src/eval/debugger.rs +++ b/src/eval/debugger.rs @@ -56,7 +56,7 @@ pub enum DebuggerCommand { pub enum DebuggerStatus { // Stop at the next statement or expression. Next(bool, bool), - // Run to the end of the current function call. + // Run to the end of the current level of function call. FunctionExit(usize), } @@ -193,7 +193,6 @@ impl BreakPoint { } /// A function call. -#[cfg(not(feature = "no_function"))] #[derive(Debug, Clone, Hash)] pub struct CallStackFrame { /// Function name. @@ -206,7 +205,6 @@ pub struct CallStackFrame { pub pos: Position, } -#[cfg(not(feature = "no_function"))] impl fmt::Display for CallStackFrame { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut fp = f.debug_tuple(&self.fn_name); @@ -239,7 +237,6 @@ pub struct Debugger { /// The current set of break-points. break_points: Vec, /// The current function call stack. - #[cfg(not(feature = "no_function"))] call_stack: Vec, } @@ -260,7 +257,6 @@ impl Debugger { Dynamic::UNIT }, break_points: Vec::new(), - #[cfg(not(feature = "no_function"))] call_stack: Vec::new(), } } @@ -277,26 +273,17 @@ impl Debugger { &mut self.state } /// Get the current call stack. - /// - /// Not available under `no_function`. - #[cfg(not(feature = "no_function"))] #[inline(always)] #[must_use] pub fn call_stack(&self) -> &[CallStackFrame] { &self.call_stack } /// Rewind the function call stack to a particular depth. - /// - /// Not available under `no_function`. - #[cfg(not(feature = "no_function"))] #[inline(always)] pub(crate) fn rewind_call_stack(&mut self, len: usize) { self.call_stack.truncate(len); } /// Add a new frame to the function call stack. - /// - /// Not available under `no_function`. - #[cfg(not(feature = "no_function"))] #[inline(always)] pub(crate) fn push_call_stack_frame( &mut self, diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 7550c3ab..0b87a2dd 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -11,12 +11,9 @@ mod target; #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] pub use chaining::{ChainArgument, ChainType}; #[cfg(feature = "debugging")] -#[cfg(not(feature = "no_function"))] -pub use debugger::CallStackFrame; -#[cfg(feature = "debugging")] pub use debugger::{ - BreakPoint, Debugger, DebuggerCommand, DebuggerEvent, DebuggerStatus, OnDebuggerCallback, - OnDebuggingInit, + BreakPoint, CallStackFrame, Debugger, DebuggerCommand, DebuggerEvent, DebuggerStatus, + OnDebuggerCallback, OnDebuggingInit, }; pub use eval_context::EvalContext; pub use eval_state::EvalState;