This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
forked from mitchellh/go-z3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
65 lines (56 loc) · 1.94 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package z3
import (
"unsafe"
)
// #include <stdlib.h>
// #include "go-z3.h"
import "C"
// Config is used to set configuration for Z3. This should be created with
// NewConfig and closed with Close when you're done using it.
//
// Config structures are used to set parameters for Z3 behavior. See the
// Z3 docs for information on available parameters. They can be set with
// SetParamValue.
//
// As for 2016-03-02, the parameters available are documented as:
//
// proof (Boolean) Enable proof generation
// debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting
// trace (Boolean) Tracing support for VCC
// trace_file_name (String) Trace out file for VCC traces
// timeout (unsigned) default timeout (in milliseconds) used for solvers
// well_sorted_check type checker
// auto_config use heuristics to automatically select solver and configure it
// model model generation for solvers, this parameter can be overwritten when creating a solver
// model_validate validate models produced by solvers
// unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver
//
type Config struct {
raw C.Z3_config
}
// NewConfig allocates a new configuration object.
func NewConfig() *Config {
return &Config{
raw: C.Z3_mk_config(),
}
}
// Close frees the memory associated with this configuration
func (c *Config) Close() error {
C.Z3_del_config(c.raw)
return nil
}
// SetParamValue sets the parameters for a Config. See the Config docs.
func (c *Config) SetParamValue(k, v string) {
ck := C.CString(k)
cv := C.CString(v)
// We free the strings since they're not actually stored
defer C.free(unsafe.Pointer(ck))
defer C.free(unsafe.Pointer(cv))
C.Z3_set_param_value(c.raw, ck, cv)
}
// Z3Value returns the raw internal pointer value. This should only be
// used if you really understand what you're doing. It may be invalid after
// Close is called.
func (c *Config) Z3Value() C.Z3_config {
return c.raw
}