Skip to content

Commit

Permalink
Allow user to send and recieve custom messages to and from the SMT so…
Browse files Browse the repository at this point in the history
…lver (#31)

Fixes #30
  • Loading branch information
UnsignedByte authored Oct 7, 2024
1 parent 023a922 commit 1a4f99c
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,32 @@ impl Context {
.list(vec![self.atoms.pop, self.arena.atom(n.to_string())]),
)
}

/// Directly send an expression to the solver.
/// This is a low-level API and should be used sparingly, such as
/// for solver-specific commands that this crate does not provide
/// built-in support for. If possible, please use the higher-level
/// interfaces provided by this crate.
pub fn raw_send(&mut self, cmd: SExpr) -> io::Result<()> {
let solver = self
.solver
.as_mut()
.expect("send requires a running solver");
solver.send(&self.arena, cmd)
}

/// Directly receive a response from the solver.
/// This is a low-level API and should be used sparingly, such as
/// for solver-specific commands that this crate does not provide
/// built-in support for. If possible, please use the higher-level
/// interfaces provided by this crate.
pub fn raw_recv(&mut self) -> io::Result<SExpr> {
let solver = self
.solver
.as_mut()
.expect("recv requires a running solver");
solver.recv(&self.arena)
}
}

/// # Basic S-Expression Construction and Inspection
Expand Down Expand Up @@ -655,8 +681,7 @@ impl Context {
I: IntoIterator<Item = (N, SExpr)>,
N: Into<String> + AsRef<str>,
{
let vars_iter =
vars
let vars_iter = vars
.into_iter()
.map(|(n, s)| self.list(vec![self.atom(n), s]));
self.list(vec![
Expand All @@ -672,8 +697,7 @@ impl Context {
I: IntoIterator<Item = (N, SExpr)>,
N: Into<String> + AsRef<str>,
{
let vars_iter =
vars
let vars_iter = vars
.into_iter()
.map(|(n, s)| self.list(vec![self.atom(n), s]));
self.list(vec![
Expand Down

0 comments on commit 1a4f99c

Please sign in to comment.