Skip to content

Commit

Permalink
Implement (exit) command (#32)
Browse files Browse the repository at this point in the history
Implement the `(exit)` command.

This helps to support graceful solver exit, which is especially
important for clients which create many `easy-smt` contexts.

The `(exit)` command is specified in SMT-LIB 2.6 section 4.2.1
"(Re)starting and terminating".
  • Loading branch information
mmcloughlin authored Nov 21, 2024
1 parent 92f6261 commit f48f8fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ impl Context {
)
}

/// Instruct the solver to exit.
pub fn exit(&mut self) -> io::Result<()> {
let solver = self
.solver
.as_mut()
.expect("exit requires a running solver");
solver.ack_command(
&self.arena,
self.atoms.success,
self.arena.list(vec![self.atoms.exit]),
)
}

/// Push a new context frame in the solver. Same as SMTLIB's `push` command.
pub fn push(&mut self) -> io::Result<()> {
let solver = self
Expand Down
1 change: 1 addition & 0 deletions src/known_atoms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ macro_rules! for_each_known_atom {
get_unsat_core: "get-unsat-core";
set_logic: "set-logic";
set_option: "set-option";
exit: "exit";
push: "push";
pop: "pop";
bool: "Bool";
Expand Down

0 comments on commit f48f8fb

Please sign in to comment.