Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
mverzilli committed Oct 5, 2023
1 parent 43fecda commit c176f77
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
51 changes: 29 additions & 22 deletions tooling/debugger/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use acvm::acir::circuit::OpcodeLocation;
use acvm::pwg::{ACVMStatus, ErrorLocation, OpcodeResolutionError, ACVM};
use acvm::BlackBoxFunctionSolver;
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap};
use acvm::acir::circuit::OpcodeLocation;

use nargo::artifacts::debug::DebugArtifact;
use nargo::errors::ExecutionError;
Expand All @@ -11,7 +11,7 @@ use nargo::ops::ForeignCallExecutor;

use thiserror::Error;

use easy_repl::{Repl, CommandStatus, command, Critical};
use easy_repl::{command, CommandStatus, Critical, Repl};
use std::cell::RefCell;

enum SolveResult {
Expand Down Expand Up @@ -79,7 +79,8 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> {
}))
}
ACVMStatus::RequiresForeignCall(foreign_call) => {
let foreign_call_result = self.foreign_call_executor.execute(&foreign_call, self.show_output)?;
let foreign_call_result =
self.foreign_call_executor.execute(&foreign_call, self.show_output)?;
self.acvm.as_mut().unwrap().resolve_pending_foreign_call(foreign_call_result);
Ok(SolveResult::Ok)
}
Expand All @@ -104,7 +105,7 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> {
println!("At {}:{start}-{end}", file.path.as_path().display());
println!("\n{}\n", &source[start..end]);
}
},
}
None => {}
}
}
Expand All @@ -113,7 +114,7 @@ impl<'backend, B: BlackBoxFunctionSolver> DebugContext<'backend, B> {
loop {
match self.step_opcode()? {
SolveResult::Done => break,
SolveResult::Ok => {},
SolveResult::Ok => {}
}
}
Ok(SolveResult::Done)
Expand All @@ -132,7 +133,7 @@ impl From<nargo::errors::NargoError> for DebuggingError {
fn map_command_status(result: SolveResult) -> CommandStatus {
match result {
SolveResult::Ok => CommandStatus::Done,
SolveResult::Done => CommandStatus::Quit
SolveResult::Done => CommandStatus::Quit,
}
}

Expand Down Expand Up @@ -168,22 +169,28 @@ pub fn debug_circuit<B: BlackBoxFunctionSolver>(
};

let mut repl = Repl::builder()
.add("s", command! {
"step to the next opcode",
() => || {
let result = ref_step.borrow_mut().step_opcode().into_critical()?;
ref_step.borrow().show_current_vm_status();
handle_result(result)
}
})
.add("c", command! {
"continue execution until the end of the program",
() => || {
println!("(Continuing execution...)");
let result = ref_cont.borrow_mut().cont().into_critical()?;
handle_result(result)
}
})
.add(
"s",
command! {
"step to the next opcode",
() => || {
let result = ref_step.borrow_mut().step_opcode().into_critical()?;
ref_step.borrow().show_current_vm_status();
handle_result(result)
}
},
)
.add(
"c",
command! {
"continue execution until the end of the program",
() => || {
println!("(Continuing execution...)");
let result = ref_cont.borrow_mut().cont().into_critical()?;
handle_result(result)
}
},
)
.build()
.expect("Failed to initialize debugger repl");

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo/src/ops/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use self::execute::execute_circuit;
pub use self::foreign_calls::ForeignCallExecutor;
pub use self::optimize::{optimize_contract, optimize_program};
pub use self::test::{run_test, TestStatus};
pub use self::foreign_calls::ForeignCallExecutor;

mod execute;
mod foreign_calls;
Expand Down
6 changes: 2 additions & 4 deletions tooling/nargo_cli/src/cli/debug_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use acvm::acir::native_types::WitnessMap;
use clap::Args;

use nargo::artifacts::debug::DebugArtifact;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::package::Package;
use nargo::artifacts::debug::DebugArtifact;
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::input_parser::{Format, InputValue};
use noirc_abi::InputMap;
Expand Down Expand Up @@ -116,8 +116,6 @@ pub(crate) fn debug_program(
);
match solved_witness_err {
Ok(solved_witness) => Ok(solved_witness),
Err(err) => {
Err(crate::errors::CliError::NargoError(err))
}
Err(err) => Err(crate::errors::CliError::NargoError(err)),
}
}

0 comments on commit c176f77

Please sign in to comment.