Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to send and recieve custom messages to and from the SMT solver #31

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading