Allow initialization of EvalState tag and separate debugger state into separate variable.

This commit is contained in:
Stephen Chung
2022-05-21 21:44:12 +08:00
parent 5435fdb8c8
commit 1abec0a8a8
10 changed files with 86 additions and 25 deletions

View File

@@ -57,10 +57,18 @@ fn test_debugger_state() -> Result<(), Box<EvalAltResult>> {
},
|mut context, _, _, _, _| {
// Print debugger state - which is an object map
println!("Current state = {}", context.tag());
println!(
"Current state = {}",
context.global_runtime_state_mut().debugger.state()
);
// Modify state
let mut state = context.tag_mut().write_lock::<Map>().unwrap();
let mut state = context
.global_runtime_state_mut()
.debugger
.state_mut()
.write_lock::<Map>()
.unwrap();
let hello = state.get("hello").unwrap().as_int().unwrap();
state.insert("hello".into(), (hello + 1).into());
state.insert("foo".into(), true.into());