mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 19:05:51 +00:00
merged
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
commit
9ab1210cc2
518 changed files with 21452 additions and 22650 deletions
14
src/api/ml/Makefile
Normal file
14
src/api/ml/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
# to set ARGS, invoke as e.g.: $ make ARGS='-DUNSAFE_ERRORS -DLEAK_CONTEXTS'
|
||||
ARGS=
|
||||
|
||||
|
||||
default: z3.ml z3.mli z3_stubs.c
|
||||
|
||||
|
||||
%.ml %.mli %_stubs.c: ../%_api.h %.0.idl x3.ml x3V3.ml x3V3.mli \
|
||||
error_handling.idl mlx_get_app_args.idl mlx_get_array_sort.idl mlx_get_datatype_sort.idl mlx_get_domains.idl mlx_get_error_msg.idl mlx_get_pattern_terms.idl mlx_get_tuple_sort.idl mlx_mk_context_x.idl mlx_mk_datatypes.idl mlx_mk_numeral.idl mlx_mk_sort.idl mlx_mk_symbol.idl mlx_model.idl mlx_numeral_refine.idl mlx_parse_smtlib.idl mlx_sort_refine.idl mlx_statistics.idl mlx_symbol_refine.idl mlx_term_refine.idl \
|
||||
generate_mlapi.sh add_error_checking.V3.sed add_error_checking.sed preprocess.sed postprocess.sed reverse.sed
|
||||
./generate_mlapi.sh $(ARGS)
|
||||
|
||||
clean:
|
||||
rm -f z3.ml z3.mli z3_stubs.c
|
69
src/api/ml/Makefile.build
Normal file
69
src/api/ml/Makefile.build
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Makefile to compile OCaml interface to Z3
|
||||
#
|
||||
# Parameters: ARGS and DEPS environment variables
|
||||
# ARGS is passed through to the Makefile that generates the OCaml interface
|
||||
# DEPS is a sequence of files that are deleted when the OCaml interface changes
|
||||
|
||||
SRC_ML=../../../src/api/ml
|
||||
ifeq (${OS}, Windows_NT)
|
||||
# the BLD_ML path ends up stored in z3.cm{,x}a, so it must be in windows format
|
||||
BLD_ML=$(shell cygpath -m $(CURDIR))
|
||||
CFLAGS=-ccopt -wd4090 -ccopt -I$(SRC_ML)/..
|
||||
XCDBG=-g $(CFLAGS)
|
||||
XCOPT=-ccopt -Ox -ccopt -Oy- $(CFLAGS)
|
||||
# ole32 is needed by camlidl (COM support)
|
||||
XLIB=-cclib ole32.lib
|
||||
AR=lib /nologo /LIBPATH:../../build ../../z3.lib /out:
|
||||
O=obj
|
||||
A=lib
|
||||
else
|
||||
BLD_ML=$(CURDIR)
|
||||
CFLAGS=-ccopt -Wno-discard-qual -ccopt -Wno-unused-variable -ccopt -I$(SRC_ML)/..
|
||||
XCDBG=-g -ccopt -g $(CFLAGS)
|
||||
XCOPT=-ccopt -O3 -ccopt -fomit-frame-pointer $(CFLAGS)
|
||||
XLIB=
|
||||
AR=ar rcs # note trailing space is significant
|
||||
O=o
|
||||
A=a
|
||||
endif
|
||||
|
||||
|
||||
all: z3.cma z3.cmxa ocamlz3
|
||||
|
||||
|
||||
# keep these files to avoid repeatedly rebuilding them
|
||||
.PRECIOUS: $(SRC_ML)/z3.ml $(SRC_ML)/z3.mli $(SRC_ML)/z3_stubs.c z3.ml z3.mli z3_stubs.c z3_theory_stubs.c
|
||||
|
||||
# regenerate OCaml API if needed
|
||||
$(SRC_ML)/%.mli $(SRC_ML)/%.ml $(SRC_ML)/%_stubs.c: $(SRC_ML)/Makefile
|
||||
make -C $(SRC_ML) z3.mli z3.ml z3_stubs.c
|
||||
|
||||
# copy OCaml API from src to build directories
|
||||
%.mli %.ml %_stubs.c %_theory_stubs.c: $(SRC_ML)/%.mli $(SRC_ML)/%.ml $(SRC_ML)/%_stubs.c Makefile
|
||||
cp $(SRC_ML)/z3.mli $(SRC_ML)/z3.ml $(SRC_ML)/z3_stubs.c $(SRC_ML)/z3_theory_stubs.c .
|
||||
|
||||
# OCaml library module for native code clients
|
||||
%.cmxa %.cmi lib%stubs.a %.a: %.mli %.ml %_stubs.c %_theory_stubs.c Makefile
|
||||
rm -f $(DEPS)
|
||||
ocamlopt.opt -c $(XCOPT) z3.mli z3.ml z3_stubs.c z3_theory_stubs.c
|
||||
$(AR)libz3stubs.$(A) z3.$(O) z3_stubs.$(O) z3_theory_stubs.$(O)
|
||||
ocamlopt.opt -a -cclib -L$(BLD_ML)/../.. $(XLIB) -cclib -lcamlidl -cclib -lz3 -cclib -lz3stubs z3.cmx -o z3.cmxa
|
||||
rm -f z3_theory_stubs.$(O) z3_stubs.$(O) z3.$(O) z3.cmx
|
||||
|
||||
# OCaml library module for byte code clients
|
||||
%.cma %.cmi lib%stubs_dbg.a: %.mli %.ml %_stubs.c %_theory_stubs.c Makefile
|
||||
rm -f $(DEPS)
|
||||
ocamlc.opt -c $(XCDBG) z3.mli z3.ml z3_stubs.c z3_theory_stubs.c
|
||||
$(AR)libz3stubs_dbg.$(A) z3_stubs.$(O) z3_theory_stubs.$(O)
|
||||
ocamlc.opt -custom -a $(CXDBG) -cclib -L$(BLD_ML)/../.. $(XLIB) -cclib -lcamlidl -cclib -lz3 -cclib -lz3stubs_dbg z3.cmo -o z3.cma
|
||||
rm -f z3_theory_stubs.$(O) z3_stubs.$(O) z3.cmo
|
||||
|
||||
|
||||
# OCaml custom toplevel system pre-linked with Z3
|
||||
ocamlz3: z3.cma Makefile
|
||||
ocamlmktop -o ocamlz3 z3.cma -cclib -L.
|
||||
|
||||
|
||||
clean: Makefile
|
||||
make -C $(SRC_ML) clean
|
||||
rm -rf Makefile libz3stubs.$(A) libz3stubs_dbg.$(A) ocamlz3 ocamlz3.dSYM z3.$(O) z3.$(A) z3.cma z3.cmi z3.cmo z3.cmx z3.cmxa z3.ml z3.mli z3_stubs.$(O) z3_stubs.c z3_theory_stubs.$(O) z3_theory_stubs.c
|
|
@ -1,2 +1,2 @@
|
|||
# Customize error handling for contexts created in ML:
|
||||
s/Z3_API Z3_mk_context\(_rc\|\)(\(.*\))/Z3_API Z3_mk_context\1(\2) quote(dealloc,\"Z3_set_error_handler(_res, caml_z3_error_handler);\")/g
|
||||
s/Z3_API Z3_mk_context(\(.*\))/Z3_API Z3_mk_context(\1) quote(dealloc,\"Z3_set_error_handler(_res, (void*)caml_z3_error_handler);\")/g
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
|
||||
# Add error checking epilogue for all Z3_API functions that accept two Z3_contexts
|
||||
:begincc
|
||||
# add epilogue for two Z3_context parameters
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\")\7/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
# add epilogue for two Z3_context parameters and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with two Z3_contexts
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endcc
|
||||
/Z3_API .*(.*);[ ]*$/b endcc
|
||||
/Z3_API .*(.*)[ ]*$/b endcc
|
||||
|
||||
# if incomplete prototype
|
||||
/Z3_API .*(.*/{
|
||||
|
@ -18,10 +23,14 @@ t endt
|
|||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for two Z3_context parameters
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")\7/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
# add epilogue for two Z3_context parameters and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")/g
|
||||
t endt
|
||||
|
||||
# else keep looking for two Z3_contexts
|
||||
|
@ -31,14 +40,19 @@ t endt
|
|||
|
||||
# Add error checking epilogue for all Z3_API functions that accept one Z3_context
|
||||
:beginc
|
||||
# add epilogue for one Z3_context parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
# add epilogue for one Z3_context parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with all Z3_contexts
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endc
|
||||
/Z3_API .*(.*);[ ]*$/b endc
|
||||
/Z3_API .*(.*)[ ]*$/b endc
|
||||
|
||||
# if incomplete prototype
|
||||
/Z3_API .*(.*/{
|
||||
|
@ -46,10 +60,14 @@ t endt
|
|||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for one Z3_context parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
# add epilogue for one Z3_context parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\")/g
|
||||
t endt
|
||||
|
||||
# else keep looking for one Z3_context
|
||||
|
@ -60,24 +78,33 @@ t endt
|
|||
|
||||
# Add error checking epilogue for all Z3_API functions that accept a Z3_theory
|
||||
:begint
|
||||
# add epilogue for one Z3_theory parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
# add epilogue for one Z3_theory parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with all Z3_theorys
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endt
|
||||
/Z3_API .*(.*);[ ]*$/b endt
|
||||
/Z3_API .*(.*)[ ]*$/b endt
|
||||
|
||||
/Z3_API .*(.*/{
|
||||
|
||||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for one Z3_theory parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_theorys
|
||||
# add epilogue for one Z3_theory parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g
|
||||
t endt
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g
|
||||
t endt
|
||||
|
||||
# else keep looking for one Z3_theory
|
||||
|
|
|
@ -53,6 +53,12 @@ Author:
|
|||
#endif
|
||||
|
||||
|
||||
// The V3 API uses a single handler irregardless of UNSAFE_ERRORS
|
||||
quote(c,"
|
||||
/* All contexts share the same handler */
|
||||
static value caml_z3_error_handler = 0;
|
||||
");
|
||||
|
||||
#ifdef SAFE_ERRORS
|
||||
|
||||
quote(mlmli,"
|
||||
|
@ -64,7 +70,7 @@ quote(mlmli,"
|
|||
exception Error of context * error_code
|
||||
");
|
||||
quote(ml,"
|
||||
/* Register dynamically-generated exception tag for use from C */
|
||||
(* Register dynamically-generated exception tag for use from C *)
|
||||
let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK))
|
||||
");
|
||||
|
||||
|
@ -108,7 +114,7 @@ quote(mlmli,"
|
|||
exception Error of context * error_code
|
||||
");
|
||||
quote(ml,"
|
||||
/* Register dynamically-generated exception tag for use from C */
|
||||
(* Register dynamically-generated exception tag for use from C *)
|
||||
let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK))
|
||||
");
|
||||
|
||||
|
@ -116,9 +122,6 @@ quote(c,"
|
|||
/* Error checking routine that does nothing */
|
||||
void check_error_code(Z3_context c) {}
|
||||
|
||||
/* All contexts share the same handler */
|
||||
static value caml_error_handler = 0;
|
||||
|
||||
static void error_handler_static (Z3_context c, Z3_error_code e)
|
||||
{
|
||||
static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
|
||||
|
@ -126,8 +129,8 @@ static void error_handler_static (Z3_context c, Z3_error_code e)
|
|||
value ctx_err[2];
|
||||
ctx_err[0] = c2ml_Z3_context(&c);
|
||||
ctx_err[1] = camlidl_c2ml_z3_Z3_error_code(&e, &_ctxs);
|
||||
if (caml_error_handler) {
|
||||
caml_callback2(caml_error_handler, ctx_err[0], ctx_err[1]);
|
||||
if (caml_z3_error_handler) {
|
||||
caml_callback2(caml_z3_error_handler, ctx_err[0], ctx_err[1]);
|
||||
} else {
|
||||
/* if no handler set, raise OCaml Error exception */
|
||||
exn_tag = caml_named_value(\"Z3.Error\");
|
||||
|
@ -141,7 +144,7 @@ static void error_handler_static (Z3_context c, Z3_error_code e)
|
|||
|
||||
void ml2c_Z3_error_handler (value ml_handler, void* c_handler)
|
||||
{
|
||||
caml_error_handler = ml_handler;
|
||||
caml_z3_error_handler = ml_handler;
|
||||
c_handler = (void*)error_handler_static;
|
||||
}
|
||||
|
||||
|
|
53
src/api/ml/generate_mlapi.sh
Executable file
53
src/api/ml/generate_mlapi.sh
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to generate the Z3 OCaml API
|
||||
#
|
||||
# Assumes that environment variables are set to provide access to the following commands: camlidl, gcc, grep, sed
|
||||
#
|
||||
# This script uses 'gcc -E' as the C preprocessor, other C preprocessors may work but have not been tested.
|
||||
#
|
||||
# Invoke with "-DUNSAFE_ERRORS" to build version that does not support recoverable errors, but avoids some error-checking overhead.
|
||||
# Invoke with "-DLEAK_CONTEXTS" to build version that leaks Z3_context objects, but avoids some garbage-collection overhead.
|
||||
|
||||
|
||||
# add calls to error checking routine
|
||||
# convert from doxygen to ocamldoc markup and other syntactic munging
|
||||
# ../z3_api.h -> z3V3_api.idl
|
||||
sed -f add_error_checking.V3.sed -f preprocess.sed ../z3_api.h > z3V3_api.idl
|
||||
|
||||
# z3.idl (z3V3_api.idl x3V3.mli x3V3.ml) -> z3V3_stubs.c, z3V3.mli, z3V3.ml
|
||||
gcc -E -w -P -CC -xc -DCAMLIDL -DMLAPIV3 $@ z3.0.idl > z3V3.idl
|
||||
camlidl -nocpp z3V3.idl
|
||||
|
||||
# reverse.sed to reverse order of substitution of enums to avoid matching prefixes such as enum_1 of enum_10
|
||||
grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_]*$" z3V3.mli | sed -e "s|and z3_\([a-zA-Z0-9_]*\) = \([a-zA-Z0-9_]*\)|s/\2/\1/g|g" -f reverse.sed > /tmp/renameV3.sed
|
||||
grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_ ]* option$" z3V3.mli | sed -e "s|and \(z3_[a-zA-Z0-9_]*\) = \([a-zA-Z0-9_ ]*\)|s/\1/\2/g|g" >> /tmp/renameV3.sed
|
||||
|
||||
# rename.sed to substitute out type equations for enums and options, then postprocess
|
||||
cp -f z3V3.mli z3V3.ml /tmp
|
||||
sed -f /tmp/renameV3.sed -f postprocess.sed /tmp/z3V3.mli > z3V3.mli
|
||||
sed -f /tmp/renameV3.sed -f postprocess.sed /tmp/z3V3.ml > z3V3.ml
|
||||
|
||||
# ../z3_api.h -> z3_api.idl
|
||||
sed -f add_error_checking.sed -f preprocess.sed ../z3_api.h > z3_api.idl
|
||||
|
||||
# z3.idl (z3_api.idl x3.ml) -> z3_stubs.c, z3.mli, z3.ml
|
||||
gcc -E -w -P -CC -xc -I. -DCAMLIDL $@ z3.0.idl > z3.idl
|
||||
camlidl -nocpp z3.idl
|
||||
|
||||
# reverse.sed to reverse order of substitution of enums to avoid matching prefixes such as enum_1 of enum_10
|
||||
grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_]*$" z3.mli | sed -e "s|and z3_\([a-zA-Z0-9_]*\) = \([a-zA-Z0-9_]*\)|s/\2/\1/g|g" -f reverse.sed > /tmp/rename.sed
|
||||
grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_ ]* option$" z3.mli | sed -e "s|and \(z3_[a-zA-Z0-9_]*\) = \([a-zA-Z0-9_ ]*\)|s/\1/\2/g|g" >> /tmp/rename.sed
|
||||
|
||||
# rename.sed to substitute out type equations for enums and options, then postprocess
|
||||
cp z3.mli z3.ml /tmp
|
||||
sed -f /tmp/rename.sed -f postprocess.sed /tmp/z3.mli > z3.mli
|
||||
sed -f /tmp/rename.sed -f postprocess.sed /tmp/z3.ml > z3.ml
|
||||
|
||||
|
||||
# append Z3.V3 module onto Z3 module
|
||||
cat z3V3.mli >> z3.mli
|
||||
cat z3V3.ml >> z3.ml
|
||||
sed "1,22d" z3V3_stubs.c >> z3_stubs.c
|
||||
|
||||
rm -f z3V3_api.idl z3V3.idl z3V3.ml z3V3.mli z3V3_stubs.c z3_api.idl z3.idl
|
8
src/api/ml/postprocess.sed
Normal file
8
src/api/ml/postprocess.sed
Normal file
|
@ -0,0 +1,8 @@
|
|||
# remove 'z3_' and 'Z3_' prefixes on names
|
||||
|
||||
s/{\!Z3\./{\!/g
|
||||
s/\([^_]\)[zZ]3_/\1/g
|
||||
|
||||
# remove cyclic definitions introduced by substituting type equations
|
||||
|
||||
s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g
|
|
@ -1,7 +1,7 @@
|
|||
# attempt to clean up the mess with 'unsigned'
|
||||
s/__in unsigned __/__in __/g
|
||||
s/__out unsigned __/__out __/g
|
||||
s/__out_opt unsigned __/__out_opt __/g
|
||||
s/ unsigned/ unsigned int/g
|
||||
s/unsigned int long/unsigned long/g
|
||||
s/unsigned int __/unsigned __/g
|
||||
|
||||
|
||||
# '@name ' -> 'Section: '
|
||||
|
@ -43,7 +43,7 @@ s/\\ / /g
|
|||
s/\\c \([^ .,:]*\)/[\1]/g
|
||||
|
||||
# '#Z3_' -> 'Z3.'
|
||||
s/#Z3_\([^ \n\.\t,)]*\)/{!Z3.\1}/g
|
||||
s/#Z3_\([^ \.,) ]*\)/{!Z3.\1}/g
|
||||
|
||||
# '/*@}*/' -> ''
|
||||
s/\/\*@{\*\///g
|
3
src/api/ml/reverse.sed
Normal file
3
src/api/ml/reverse.sed
Normal file
|
@ -0,0 +1,3 @@
|
|||
# output lines of input in reverse order
|
||||
|
||||
1!G;h;$!d
|
|
@ -91,16 +91,6 @@ quote(c,"#define xstr(s) str(s)");
|
|||
quote(c,"#define str(s) #s");
|
||||
|
||||
|
||||
// CamlIDL (1.05) has a bug where it does not accept [unsigned] as a type,
|
||||
// only as a specifier, so unsigned is defined to be unsigned int.
|
||||
#define unsigned unsigned int
|
||||
|
||||
|
||||
// Suppress "warning C4090: 'function' : different 'const' qualifiers" as
|
||||
// CamlIDL does not seem to get this right.
|
||||
quote(c,"#pragma warning(disable:4090)");
|
||||
|
||||
|
||||
#ifndef MLAPIV3
|
||||
|
||||
#define DEFINE_TYPE(T) typedef [abstract] void* T
|
|
@ -4886,7 +4886,8 @@ external fixedpoint_add_rule : context -> fixedpoint -> ast -> symbol -> unit
|
|||
of sorts in the domain of [r]. Each sort in the domain should be an integral
|
||||
(bit-vector, Boolean or or finite domain sort).
|
||||
|
||||
The call has the same effect as adding a rule where
is applied to the arguments.
|
||||
The call has the same effect as adding a rule where
|
||||
is applied to the arguments.
|
||||
|
||||
def_API('fixedpoint_add_fact', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL), _in(UINT), _in_array(3, UINT)))
|
||||
*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue