49 if (output !=
nullptr) {
52 if (handle ==
nullptr || output ==
nullptr) {
53 if (handle !=
nullptr) {
60 std::string result = fn();
61 char *buffer =
static_cast<char *
>(std::malloc(result.size() + 1));
62 if (buffer ==
nullptr) {
63 throw std::bad_alloc();
65 std::memcpy(buffer, result.c_str(), result.size() + 1);
70 catch (
const std::invalid_argument &e) {
74 catch (
const std::exception &e) {
103 if (options !=
nullptr) {
113 if (options !=
nullptr) {
123 if (options !=
nullptr) {
141 if (handle ==
nullptr) {
144 auto options = current_options(handle);
145 options.set_rewrite(value);
146 apply_options(handle, options);
154 if (handle ==
nullptr) {
157 auto options = current_options(handle);
158 options.set_context_propagation(value);
159 apply_options(handle, options);
167 if (handle ==
nullptr) {
170 auto options = current_options(handle);
171 options.set_subgraph_pruning(value);
172 apply_options(handle, options);
180 if (handle ==
nullptr || file_path ==
nullptr || output ==
nullptr) {
181 if (handle !=
nullptr) {
184 if (output !=
nullptr) {
189 return capture(handle, output, [handle, file_path]() {
return handle->
stabilizer.
apply_file(file_path); });
193 if (handle ==
nullptr || smt2_text ==
nullptr || output ==
nullptr) {
194 if (handle !=
nullptr) {
197 if (output !=
nullptr) {
202 return capture(handle, output, [handle, smt2_text]() {
return handle->
stabilizer.
apply_text(smt2_text); });
206 return handle !=
nullptr ? handle->
last_error.c_str() :
"invalid handle";
void stabilizer_options_set_context_propagation(stabilizer_options *options, bool value)
Enable or disable kernel context propagation.
bool stabilizer_options_get_subgraph_pruning(const stabilizer_options *options)
Query kernel subgraph pruning/tie-breaking behavior.
bool stabilizer_get_subgraph_pruning(const stabilizer_handle *handle)
Query subgraph pruning/tie-breaking behavior on a live stabilizer.
const char * stabilizer_last_error(const stabilizer_handle *handle)
Return the last diagnostic message associated with a handle.
stabilizer_handle * stabilizer_create(const stabilizer_options *options)
Create a stabilizer instance.
bool stabilizer_options_get_context_propagation(const stabilizer_options *options)
Query kernel context propagation flag.
bool stabilizer_get_rewrite(const stabilizer_handle *handle)
Query rewrite normalization on a live stabilizer.
void stabilizer_set_subgraph_pruning(stabilizer_handle *handle, bool value)
Update subgraph pruning/tie-breaking behavior on a live stabilizer.
void stabilizer_set_rewrite(stabilizer_handle *handle, bool value)
Update rewrite normalization on a live stabilizer.
void stabilizer_options_set_rewrite(stabilizer_options *options, bool value)
Enable or disable parser rewrite normalization.
void stabilizer_options_set_subgraph_pruning(stabilizer_options *options, bool value)
Enable or disable kernel subgraph pruning/tie-breaking behavior.
void stabilizer_free_string(char *value)
Release strings returned through stabilizer_apply_*.
void stabilizer_options_destroy(stabilizer_options *options)
Release an options object created by stabilizer_options_create.
void stabilizer_set_context_propagation(stabilizer_handle *handle, bool value)
Update context propagation on a live stabilizer.
stabilizer_status stabilizer_apply_text(stabilizer_handle *handle, const char *smt2_text, char **output)
Apply stabilization pipeline to SMT-LIB2 text.
void stabilizer_destroy(stabilizer_handle *handle)
Destroy a stabilizer instance and associated internal state.
bool stabilizer_get_context_propagation(const stabilizer_handle *handle)
Query context propagation on a live stabilizer.
bool stabilizer_options_get_rewrite(const stabilizer_options *options)
Query parser rewrite normalization flag.
stabilizer_options * stabilizer_options_create(void)
Allocate a new options object with default values.
stabilizer_status stabilizer_apply_file(stabilizer_handle *handle, const char *file_path, char **output)
Apply stabilization pipeline to an SMT-LIB2 file.
Public options for the SMTStabilizer API.
bool get_subgraph_pruning() const noexcept
void set_context_propagation(bool value) noexcept
void set_subgraph_pruning(bool value) noexcept
bool get_context_propagation() const noexcept
void set_rewrite(bool rewrite) noexcept
bool get_rewrite() const noexcept
High-level facade for stabilizing SMT-LIB2 inputs.
std::string apply_file(const std::string &file_path) const
Apply the full pipeline to an SMT-LIB2 file.
std::string apply_text(const std::string &smt2_text) const
Apply the full pipeline to an SMT-LIB2 script provided as text.
const SMTStabilizerOptions & options() const noexcept
void set_options(const SMTStabilizerOptions &options) noexcept
stabilizer_status
Result status for C API calls.
@ STABILIZER_STATUS_RUNTIME_ERROR
@ STABILIZER_STATUS_INVALID_ARGUMENT
stabilizer_handle(const stabilizer_options *options)
stabilizer::api::SMTStabilizer stabilizer
stabilizer::api::SMTStabilizerOptions value