From 34dfe841cdc688fe1b944aa1392a587df8f341dc Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 24 Apr 2022 16:06:11 +0800 Subject: [PATCH] Add commands to rhai-dbg. --- src/bin/rhai-dbg.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/rhai-dbg.rs b/src/bin/rhai-dbg.rs index ffe0aae1..a78832bb 100644 --- a/src/bin/rhai-dbg.rs +++ b/src/bin/rhai-dbg.rs @@ -118,8 +118,10 @@ fn print_debug_help() { println!("help, h => print this help"); println!("quit, q, exit, kill => quit"); println!("scope => print the scope"); + println!("operations => print the total operations performed"); + println!("source => print the current source"); println!("print, p => print all variables de-duplicated"); - println!("print/p this => print the 'this' pointer"); + println!("print/p this => print the `this` pointer"); println!("print/p => print the current value of a variable"); #[cfg(not(feature = "no_module"))] println!("imports => print all imported modules"); @@ -313,6 +315,12 @@ fn debug_callback( } println!(); } + ["operations"] => { + println!("{}", context.global_runtime_state().num_operations) + } + ["source"] => { + println!("{}", context.global_runtime_state().source().unwrap_or("")) + } ["list" | "l"] => print_current_source(context, source, pos, &lines, (3, 6)), ["list" | "l", n] if n.parse::().is_ok() => { let num = n.parse::().unwrap(); @@ -333,7 +341,7 @@ fn debug_callback( if let Some(value) = context.this_ptr() { println!("=> {:?}", value); } else { - println!("'this' pointer is unbound."); + println!("`this` pointer is unbound."); } } ["print" | "p", var_name] => {