3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 20:18:18 +00:00

More Java API. This is still under heavy construction and cannot be used.

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2012-11-23 00:46:44 +00:00
parent c702454f6c
commit 520bcaf720
42 changed files with 2353 additions and 667 deletions

View file

@ -71,7 +71,7 @@ def init_project_def():
static=build_static_lib(), static=build_static_lib(),
export_files=API_files) export_files=API_files)
add_dot_net_dll('dotnet', ['api_dll'], 'api/dotnet', dll_name='Microsoft.Z3', assembly_info_dir='Properties') add_dot_net_dll('dotnet', ['api_dll'], 'api/dotnet', dll_name='Microsoft.Z3', assembly_info_dir='Properties')
add_java_dll('java', 'api/java', dll_name='libz3java') add_java_dll('java', ['api_dll'], 'api/java', dll_name='libz3java', package_name="com.Microsoft.Z3")
add_hlib('cpp', 'api/c++', includes2install=['z3++.h']) add_hlib('cpp', 'api/c++', includes2install=['z3++.h'])
set_z3py_dir('api/python') set_z3py_dir('api/python')
# Examples # Examples

View file

@ -52,6 +52,7 @@ PATTERN_COMPONENT='pattern'
UTIL_COMPONENT='util' UTIL_COMPONENT='util'
API_COMPONENT='api' API_COMPONENT='api'
DOTNET_COMPONENT='dotnet' DOTNET_COMPONENT='dotnet'
JAVA_COMPONENT='java'
CPP_COMPONENT='cpp' CPP_COMPONENT='cpp'
##################### #####################
IS_WINDOWS=False IS_WINDOWS=False
@ -921,11 +922,12 @@ class DotNetDLLComponent(Component):
class JavaDLLComponent(Component): class JavaDLLComponent(Component):
def __init__(self, name, dll_name, path): def __init__(self, name, dll_name, package_name, path, deps):
Component.__init__(self, name, path, []) Component.__init__(self, name, path, deps)
if dll_name == None: if dll_name == None:
dll_name = name dll_name = name
self.dll_name = dll_name self.dll_name = dll_name
self.package_name = package_name
def mk_makefile(self, out): def mk_makefile(self, out):
if is_java_enabled(): if is_java_enabled():
@ -942,6 +944,7 @@ class JavaDLLComponent(Component):
out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I%s %s/Z3Native.c\n' % (JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir)) out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I%s %s/Z3Native.c\n' % (JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir))
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) -L. Z3Native$(OBJ_EXT) -lz3\n' % dllfile) out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) -L. Z3Native$(OBJ_EXT) -lz3\n' % dllfile)
out.write('%s: %s\n\n' % (self.name, dllfile)) out.write('%s: %s\n\n' % (self.name, dllfile))
# TODO: Compile and package all the .class files.
def main_component(self): def main_component(self):
return is_java_enabled() return is_java_enabled()
@ -1080,8 +1083,8 @@ def add_dot_net_dll(name, deps=[], path=None, dll_name=None, assembly_info_dir=N
c = DotNetDLLComponent(name, dll_name, path, deps, assembly_info_dir) c = DotNetDLLComponent(name, dll_name, path, deps, assembly_info_dir)
reg_component(name, c) reg_component(name, c)
def add_java_dll(name, path=None, dll_name=None): def add_java_dll(name, deps=[], path=None, dll_name=None, package_name=None):
c = JavaDLLComponent(name, dll_name, path) c = JavaDLLComponent(name, dll_name, package_name, path, deps)
reg_component(name, c) reg_component(name, c)
def add_cpp_example(name, path=None): def add_cpp_example(name, path=None):
@ -1604,7 +1607,7 @@ def cp_z3pyc_to_build():
def mk_bindings(api_files): def mk_bindings(api_files):
if not ONLY_MAKEFILES: if not ONLY_MAKEFILES:
mk_z3consts_py(api_files) mk_z3consts_py(api_files)
mk_z3consts_donet(api_files) mk_z3consts_dotnet(api_files)
new_api_files = [] new_api_files = []
api = get_component(API_COMPONENT) api = get_component(API_COMPONENT)
for api_file in api_files: for api_file in api_files:
@ -1614,6 +1617,7 @@ def mk_bindings(api_files):
g["API_FILES"] = new_api_files g["API_FILES"] = new_api_files
if is_java_enabled(): if is_java_enabled():
check_java() check_java()
mk_z3consts_java(api_files)
execfile('scripts/update_api.py', g) # HACK execfile('scripts/update_api.py', g) # HACK
cp_z3pyc_to_build() cp_z3pyc_to_build()
@ -1696,7 +1700,7 @@ def mk_z3consts_py(api_files):
# Extract enumeration types from z3_api.h, and add .Net definitions # Extract enumeration types from z3_api.h, and add .Net definitions
def mk_z3consts_donet(api_files): def mk_z3consts_dotnet(api_files):
blank_pat = re.compile("^ *$") blank_pat = re.compile("^ *$")
comment_pat = re.compile("^ *//.*$") comment_pat = re.compile("^ *//.*$")
typedef_pat = re.compile("typedef enum *") typedef_pat = re.compile("typedef enum *")
@ -1779,6 +1783,94 @@ def mk_z3consts_donet(api_files):
if VERBOSE: if VERBOSE:
print "Generated '%s'" % ('%s/Enumerations.cs' % dotnet.src_dir) print "Generated '%s'" % ('%s/Enumerations.cs' % dotnet.src_dir)
# Extract enumeration types from z3_api.h, and add Java definitions
def mk_z3consts_java(api_files):
blank_pat = re.compile("^ *$")
comment_pat = re.compile("^ *//.*$")
typedef_pat = re.compile("typedef enum *")
typedef2_pat = re.compile("typedef enum { *")
openbrace_pat = re.compile("{ *")
closebrace_pat = re.compile("}.*;")
java = get_component(JAVA_COMPONENT)
DeprecatedEnums = [ 'Z3_search_failure' ]
gendir = java.src_dir + "/" + java.package_name.replace(".", "/") + "/Enumerations"
if not os.path.exists(gendir):
os.mkdir(gendir)
for api_file in api_files:
api_file_c = java.find_file(api_file, java.name)
api_file = '%s/%s' % (api_file_c.src_dir, api_file)
api = open(api_file, 'r')
SEARCHING = 0
FOUND_ENUM = 1
IN_ENUM = 2
mode = SEARCHING
decls = {}
idx = 0
linenum = 1
for line in api:
m1 = blank_pat.match(line)
m2 = comment_pat.match(line)
if m1 or m2:
# skip blank lines and comments
linenum = linenum + 1
elif mode == SEARCHING:
m = typedef_pat.match(line)
if m:
mode = FOUND_ENUM
m = typedef2_pat.match(line)
if m:
mode = IN_ENUM
decls = {}
idx = 0
elif mode == FOUND_ENUM:
m = openbrace_pat.match(line)
if m:
mode = IN_ENUM
decls = {}
idx = 0
else:
assert False, "Invalid %s, line: %s" % (api_file, linenum)
else:
assert mode == IN_ENUM
words = re.split('[^\-a-zA-Z0-9_]+', line)
m = closebrace_pat.match(line)
if m:
name = words[1]
if name not in DeprecatedEnums:
efile = open('%s/%s.java' % (gendir, name), 'w')
efile.write('/**\n * Automatically generated file\n **/\n\n')
efile.write('package %s;\n\n' % java.package_name);
efile.write('/**\n')
efile.write(' * %s\n' % name)
efile.write(' **/\n')
efile.write('public enum %s {\n' % name)
efile.write
for k, i in decls.iteritems():
efile.write('%s (%s),\n' % (k, i))
efile.write('}\n\n')
efile.close()
mode = SEARCHING
else:
if words[2] != '':
if len(words[2]) > 1 and words[2][1] == 'x':
idx = int(words[2], 16)
else:
idx = int(words[2])
decls[words[1]] = idx
idx = idx + 1
linenum = linenum + 1
if VERBOSE:
print "Generated '%s'" % ('%s' % gendir)
def mk_gui_str(id): def mk_gui_str(id):
return '4D2F40D8-E5F9-473B-B548-%012d' % id return '4D2F40D8-E5F9-473B-B548-%012d' % id

View file

@ -506,6 +506,9 @@ def mk_java():
java_native.write('// Automatically generated file\n') java_native.write('// Automatically generated file\n')
java_native.write('package com.Microsoft.Z3;\n') java_native.write('package com.Microsoft.Z3;\n')
java_native.write('public final class Native {\n') java_native.write('public final class Native {\n')
java_native.write(' public static class IntPtr { public int value; }\n')
java_native.write(' public static class LongPtr { public long value; }\n')
java_native.write(' public static class StringPtr { public String value; }\n')
if is_windows(): if is_windows():
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java')) java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java'))
@ -524,9 +527,9 @@ def mk_java():
i = i + 1 i = i + 1
java_native.write(');\n') java_native.write(');\n')
java_native.write(' public static void main(String[] args) {\n') java_native.write(' public static void main(String[] args) {\n')
java_native.write(' Integer major = 0, minor = 0, build = 0, revision = 0;\n') java_native.write(' IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr();\n')
java_native.write(' getVersion(major, minor, build, revision);\n') java_native.write(' getVersion(major, minor, build, revision);\n')
java_native.write(' System.out.format("Z3 (for Java) %d.%d.%d%n", major, minor, build);\n') java_native.write(' System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value);\n')
java_native.write(' }\n') java_native.write(' }\n')
java_native.write('}\n'); java_native.write('}\n');
java_wrapper = open(java_wrapperf, 'w') java_wrapper = open(java_wrapperf, 'w')

View file

@ -75,7 +75,7 @@ package com.Microsoft.Z3;
/** /**
* A unique identifier for the AST (unique among all ASTs). * A unique identifier for the AST (unique among all ASTs).
**/ **/
public Integer Id() { return Native.getAstId(Context.nCtx, NativeObject); } public long Id() { return Native.getAstId(Context.nCtx, NativeObject); }
/** /**
* Translates (copies) the AST to the Context <paramref name="ctx"/>. * Translates (copies) the AST to the Context <paramref name="ctx"/>.
@ -96,7 +96,7 @@ package com.Microsoft.Z3;
/** /**
* The kind of the AST. * The kind of the AST.
**/ **/
public Z3_ast_kind ASTKind() { return (Z3AstKind)Native.getAstKind(Context.nCtx, NativeObject); } public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context.nCtx, NativeObject); }
/** /**
* Indicates whether the AST is an Expr * Indicates whether the AST is an Expr
@ -105,10 +105,10 @@ package com.Microsoft.Z3;
{ {
switch (ASTKind) switch (ASTKind)
{ {
case Z3AstKind.Z3APPAST: case Z3_ast_kind.Z3_APP_AST:
case Z3AstKind.Z3NUMERALAST: case Z3_ast_kind.Z3_NUMERAL_AST:
case Z3AstKind.Z3QUANTIFIERAST: case Z3_ast_kind.Z3_QUANTIFIER_AST:
case Z3AstKind.Z3VARAST: return true; case Z3_ast_kind.Z3_VAR_AST: return true;
default: return false; default: return false;
} }
} }
@ -116,22 +116,22 @@ package com.Microsoft.Z3;
/** /**
* Indicates whether the AST is a BoundVariable * Indicates whether the AST is a BoundVariable
**/ **/
public boolean IsVar() { return this.ASTKind == Z3AstKind.Z3VARAST; } public boolean IsVar() { return this.ASTKind == Z3_ast_kind.Z3_VAR_AST; }
/** /**
* Indicates whether the AST is a Quantifier * Indicates whether the AST is a Quantifier
**/ **/
public boolean IsQuantifier() { return this.ASTKind == Z3AstKind.Z3QUANTIFIERAST; } public boolean IsQuantifier() { return this.ASTKind == Z3_ast_kind.Z3_QUANTIFIER_AST; }
/** /**
* Indicates whether the AST is a Sort * Indicates whether the AST is a Sort
**/ **/
public boolean IsSort() { return this.ASTKind == Z3AstKind.Z3SORTAST; } public boolean IsSort() { return this.ASTKind == Z3_ast_kind.Z3_SORT_AST; }
/** /**
* Indicates whether the AST is a FunctionDeclaration * Indicates whether the AST is a FunctionDeclaration
**/ **/
public boolean IsFuncDecl() { return this.ASTKind == Z3AstKind.Z3FUNCDECLAST; } public boolean IsFuncDecl() { return this.ASTKind == Z3_ast_kind.Z3_FUNC_DECL_AST; }
/** /**
* A string representation of the AST. * A string representation of the AST.
@ -174,7 +174,7 @@ package com.Microsoft.Z3;
throw new Z3Exception("inc() called on null context"); throw new Z3Exception("inc() called on null context");
if (o == IntPtr.Zero) if (o == IntPtr.Zero)
throw new Z3Exception("inc() called on null AST"); throw new Z3Exception("inc() called on null AST");
Context.ASTDRQ.IncAndClear(Context, o); Context.AST_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
@ -185,7 +185,7 @@ package com.Microsoft.Z3;
throw new Z3Exception("dec() called on null context"); throw new Z3Exception("dec() called on null context");
if (o == IntPtr.Zero) if (o == IntPtr.Zero)
throw new Z3Exception("dec() called on null AST"); throw new Z3Exception("dec() called on null AST");
Context.ASTDRQ.Add(o); Context.AST_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
@ -194,14 +194,14 @@ package com.Microsoft.Z3;
switch ((Z3AstKind)Native.getAstKind(ctx.nCtx, obj)) switch ((Z3_ast_kind)Native.getAstKind(ctx.nCtx, obj))
{ {
case Z3AstKind.Z3FUNCDECLAST: return new FuncDecl(ctx, obj); case Z3_ast_kind.Z3_FUNC_DECL_AST: return new FuncDecl(ctx, obj);
case Z3AstKind.Z3QUANTIFIERAST: return new Quantifier(ctx, obj); case Z3_ast_kind.Z3_QUANTIFIER_AST: return new Quantifier(ctx, obj);
case Z3AstKind.Z3SORTAST: return Sort.Create(ctx, obj); case Z3_ast_kind.Z3_SORT_AST: return Sort.Create(ctx, obj);
case Z3AstKind.Z3APPAST: case Z3_ast_kind.Z3_APP_AST:
case Z3AstKind.Z3NUMERALAST: case Z3_ast_kind.Z3_NUMERAL_AST:
case Z3AstKind.Z3VARAST: return Expr.Create(ctx, obj); case Z3_ast_kind.Z3_VAR_AST: return Expr.Create(ctx, obj);
default: default:
throw new Z3Exception("Unknown AST kind"); throw new Z3Exception("Unknown AST kind");
} }

View file

@ -73,7 +73,7 @@ package com.Microsoft.Z3;
/** /**
* The size of the map * The size of the map
**/ **/
public Integer Size() { return Native.astMapSize(Context.nCtx, NativeObject); } public long Size() { return Native.astMapSize(Context.nCtx, NativeObject); }
/** /**
* The keys stored in the map. * The keys stored in the map.
@ -115,13 +115,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ASTMapDRQ.IncAndClear(Context, o); Context.ASTMap_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ASTMapDRQ.Add(o); Context.ASTMap_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -14,7 +14,7 @@ package com.Microsoft.Z3;
/** /**
* The size of the vector * The size of the vector
**/ **/
public Integer Size() { return Native.astVectorSize(Context.nCtx, NativeObject); } public long Size() { return Native.astVectorSize(Context.nCtx, NativeObject); }
/** /**
* Retrieves the i-th object in the vector. * Retrieves the i-th object in the vector.
@ -22,24 +22,24 @@ package com.Microsoft.Z3;
* <param name="i">Index</param> * <param name="i">Index</param>
* @return An AST * @return An AST
**/ **/
public AST this[Integer i]() public AST get(long i)
{ {
return new AST(Context, Native.astVectorGet(Context.nCtx, NativeObject, i)); return new AST(Context, Native.astVectorGet(Context.nCtx, NativeObject, i));
set }
public void set(long i, AST value)
{ {
Native.astVectorSet(Context.nCtx, NativeObject, i, value.NativeObject); Native.astVectorSet(Context.nCtx, NativeObject, i, value.NativeObject);
} }
}
/** /**
* Resize the vector to <paramref name="newSize"/>. * Resize the vector to <paramref name="newSize"/>.
* <param name="newSize">The new size of the vector.</param> * <param name="newSize">The new size of the vector.</param>
**/ **/
public void Resize(Integer newSize) public void Resize(long newSize)
{ {
Native.astVectorResize(Context.nCtx, NativeObject, newSize); Native.astVectorResize(Context.nCtx, NativeObject, newSize);
} }
@ -95,13 +95,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ASTVectorDRQ.IncAndClear(Context, o); Context.ASTVector_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ASTVectorDRQ.Add(o); Context.ASTVector_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -15,7 +15,7 @@ package com.Microsoft.Z3;
/** /**
* The number of Subgoals. * The number of Subgoals.
**/ **/
public Integer NumSubgoals() { return Native.applyResultGetNumSubgoals(Context.nCtx, NativeObject); } public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context.nCtx, NativeObject); }
/** /**
* Retrieves the subgoals from the ApplyResult. * Retrieves the subgoals from the ApplyResult.
@ -25,9 +25,9 @@ package com.Microsoft.Z3;
Integer n = NumSubgoals; long n = NumSubgoals;
Goal[] res = new Goal[n]; Goal[] res = new Goal[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context.nCtx, NativeObject, i)); res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -37,7 +37,7 @@ package com.Microsoft.Z3;
* goal <code>g</code>, that the ApplyResult was obtained from. * goal <code>g</code>, that the ApplyResult was obtained from.
* @return A model for <code>g</code> * @return A model for <code>g</code>
**/ **/
public Model ConvertModel(Integer i, Model m) public Model ConvertModel(long i, Model m)
{ {
@ -72,13 +72,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ApplyResultDRQ.IncAndClear(Context, o); Context.ApplyResult_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ApplyResultDRQ.Add(o); Context.ApplyResult_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -14,28 +14,41 @@ package com.Microsoft.Z3;
/** /**
* The number of fields of the constructor. * The number of fields of the constructor.
**/ **/
public Integer NumFields() { init(); return n; } public long NumFields()
{
init();
return n;
}
/** /**
* The function declaration of the constructor. * The function declaration of the constructor.
**/ **/
public FuncDecl ConstructorDecl() { public FuncDecl ConstructorDecl()
{
init(); return mConstructorDecl; } init();
return m_constructorDecl;
}
/** /**
* The function declaration of the tester. * The function declaration of the tester.
**/ **/
public FuncDecl TesterDecl() { public FuncDecl TesterDecl()
{
init(); return mTesterDecl; } init();
return m_testerDecl;
}
/** /**
* The function declarations of the accessors * The function declarations of the accessors
**/ **/
public FuncDecl[] AccessorDecls() { public FuncDecl[] AccessorDecls()
{
init(); return mAccessorDecls; } init();
return m_accessorDecls;
}
/** /**
* Destructor. * Destructor.
@ -53,13 +66,13 @@ package com.Microsoft.Z3;
} }
private Integer n = 0; private long n = 0;
private FuncDecl mTesterDecl = null; private FuncDecl m_testerDecl = null;
private FuncDecl mConstructorDecl = null; private FuncDecl m_constructorDecl = null;
private FuncDecl[] mAccessorDecls = null; private FuncDecl[] m_accessorDecls = null;
Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames, Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames,
Sort[] sorts, Integer[] sortRefs) Sort[] sorts, long[] sortRefs)
{ super(ctx); { super(ctx);
@ -72,7 +85,7 @@ package com.Microsoft.Z3;
if (sortRefs != null && sortRefs.Length != n) if (sortRefs != null && sortRefs.Length != n)
throw new Z3Exception("Number of field names does not match number of sort refs"); throw new Z3Exception("Number of field names does not match number of sort refs");
if (sortRefs == null) sortRefs = new Integer[n]; if (sortRefs == null) sortRefs = new long[n];
NativeObject = Native.mkConstructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject, NativeObject = Native.mkConstructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject,
n, n,
@ -88,16 +101,16 @@ package com.Microsoft.Z3;
if (mTesterDecl != null) return; if (m_testerDecl != null) return;
IntPtr constructor = IntPtr.Zero; IntPtr constructor = IntPtr.Zero;
IntPtr tester = IntPtr.Zero; IntPtr tester = IntPtr.Zero;
IntPtr[] accessors = new IntPtr[n]; IntPtr[] accessors = new IntPtr[n];
Native.queryConstructor(Context.nCtx, NativeObject, n, constructor, tester, accessors); Native.queryConstructor(Context.nCtx, NativeObject, n, constructor, tester, accessors);
mConstructorDecl = new FuncDecl(Context, constructor); m_constructorDecl = new FuncDecl(Context, constructor);
mTesterDecl = new FuncDecl(Context, tester); m_testerDecl = new FuncDecl(Context, tester);
mAccessorDecls = new FuncDecl[n]; m_accessorDecls = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
mAccessorDecls[i] = new FuncDecl(Context, accessors[i]); m_accessorDecls[i] = new FuncDecl(Context, accessors[i]);
} }
} }
@ -125,6 +138,6 @@ package com.Microsoft.Z3;
NativeObject = Native.mkConstructorList(Context.nCtx, (Integer)constructors.Length, Constructor.ArrayToNative(constructors)); NativeObject = Native.mkConstructorList(Context.nCtx, (long)constructors.Length, Constructor.ArrayToNative(constructors));
} }
} }

View file

@ -18,7 +18,7 @@ package com.Microsoft.Z3;
**/ **/
public Context() public Context()
{ super(); { super();
mCtx = Native.mkContextRc(IntPtr.Zero); m_ctx = Native.mkContextRc(IntPtr.Zero);
InitContext(); InitContext();
} }
@ -32,7 +32,7 @@ package com.Microsoft.Z3;
IntPtr cfg = Native.mkConfig(); IntPtr cfg = Native.mkConfig();
for (KeyValuePair<String, String>.Iterator kv = settings.iterator(); kv.hasNext(); ) for (KeyValuePair<String, String>.Iterator kv = settings.iterator(); kv.hasNext(); )
Native.setParamValue(cfg, kv.Key, kv.Value); Native.setParamValue(cfg, kv.Key, kv.Value);
mCtx = Native.mkContextRc(cfg); m_ctx = Native.mkContextRc(cfg);
Native.delConfig(cfg); Native.delConfig(cfg);
InitContext(); InitContext();
} }
@ -77,9 +77,9 @@ package com.Microsoft.Z3;
return result; return result;
} }
private BoolSort mBooleanSort = null; private BoolSort m_booleanSort = null;
private IntSort mIntSort = null; private IntSort m_intSort = null;
private RealSort mRealSort = null; private RealSort m_realSort = null;
/** /**
* Retrieves the Boolean sort of the context. * Retrieves the Boolean sort of the context.
@ -88,7 +88,7 @@ package com.Microsoft.Z3;
{ {
if (mBooleanSort == null) mBooleanSort = new BoolSort(this); return mBooleanSort; if (m_booleanSort == null) m_booleanSort = new BoolSort(this); return m_booleanSort;
} }
/** /**
@ -97,14 +97,23 @@ package com.Microsoft.Z3;
public IntSort IntSort() public IntSort IntSort()
{ {
if (mIntSort == null) mIntSort = new IntSort(this); return mIntSort; if (m_intSort == null) m_intSort = new IntSort(this); return m_intSort;
} }
/** /**
* Retrieves the Real sort of the context. * Retrieves the Real sort of the context.
**/ **/
/* Overloaded operators are not translated. */ public RealSort RealSort () { return m_realSort; }
/**
* Create a new Boolean sort.
**/
public BoolSort MkBoolSort()
{
return new BoolSort(this);
}
/** /**
* Create a new uninterpreted sort. * Create a new uninterpreted sort.
@ -150,7 +159,7 @@ package com.Microsoft.Z3;
/** /**
* Create a new bit-vector sort. * Create a new bit-vector sort.
**/ **/
public BitVecSort MkBitVecSort(Integer size) public BitVecSort MkBitVecSort(long size)
{ {
@ -185,7 +194,7 @@ package com.Microsoft.Z3;
CheckContextMatch(name); CheckContextMatch(name);
CheckContextMatch(fieldNames); CheckContextMatch(fieldNames);
CheckContextMatch(fieldSorts); CheckContextMatch(fieldSorts);
return new TupleSort(this, name, (Integer)fieldNames.Length, fieldNames, fieldSorts); return new TupleSort(this, name, (long)fieldNames.Length, fieldNames, fieldSorts);
} }
/** /**
@ -274,7 +283,7 @@ package com.Microsoft.Z3;
* if the corresponding sort reference is 0, then the value in sort_refs should be an index * if the corresponding sort reference is 0, then the value in sort_refs should be an index
* referring to one of the recursive datatypes that is declared.</param> * referring to one of the recursive datatypes that is declared.</param>
**/ **/
public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, Integer[] sortRefs) public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, long[] sortRefs)
{ {
@ -292,7 +301,7 @@ package com.Microsoft.Z3;
* <param name="sortRefs"></param> * <param name="sortRefs"></param>
* @return * @return
**/ **/
public Constructor MkConstructor(String name, String recognizer, String[] fieldNames, Sort[] sorts, Integer[] sortRefs) public Constructor MkConstructor(String name, String recognizer, String[] fieldNames, Sort[] sorts, long[] sortRefs)
{ {
@ -343,22 +352,22 @@ package com.Microsoft.Z3;
CheckContextMatch(names); CheckContextMatch(names);
Integer n = (Integer)names.Length; long n = (long)names.Length;
ConstructorList[] cla = new ConstructorList[n]; ConstructorList[] cla = new ConstructorList[n];
IntPtr[] nConstr = new IntPtr[n]; IntPtr[] n_constr = new IntPtr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
{ {
var constructor = c[i]; var constructor = c[i];
CheckContextMatch(constructor); CheckContextMatch(constructor);
cla[i] = new ConstructorList(this, constructor); cla[i] = new ConstructorList(this, constructor);
nConstr[i] = cla[i].NativeObject; n_constr[i] = cla[i].NativeObject;
} }
IntPtr[] nRes = new IntPtr[n]; IntPtr[] n_res = new IntPtr[n];
Native.mkDatatypes(nCtx, n, Symbol.ArrayToNative(names), nRes, nConstr); Native.mkDatatypes(nCtx, n, Symbol.ArrayToNative(names), n_res, n_constr);
DatatypeSort[] res = new DatatypeSort[n]; DatatypeSort[] res = new DatatypeSort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new DatatypeSort(this, nRes[i]); res[i] = new DatatypeSort(this, n_res[i]);
return res; return res;
} }
@ -504,7 +513,7 @@ package com.Microsoft.Z3;
* <param name="index">The de-Bruijn index of the variable</param> * <param name="index">The de-Bruijn index of the variable</param>
* <param name="ty">The sort of the variable</param> * <param name="ty">The sort of the variable</param>
**/ **/
public Expr MkBound(Integer index, Sort ty) public Expr MkBound(long index, Sort ty)
{ {
@ -526,7 +535,7 @@ package com.Microsoft.Z3;
IntPtr[] termsNative = AST.ArrayToNative(terms); IntPtr[] termsNative = AST.ArrayToNative(terms);
return new Pattern(this, Native.mkPattern(nCtx, (Integer)terms.Length, termsNative)); return new Pattern(this, Native.mkPattern(nCtx, (long)terms.Length, termsNative));
} }
/** /**
@ -647,7 +656,7 @@ package com.Microsoft.Z3;
/** /**
* Creates a bit-vector constant. * Creates a bit-vector constant.
**/ **/
public BitVecExpr MkBVConst(Symbol name, Integer size) public BitVecExpr MkBVConst(Symbol name, long size)
{ {
@ -658,7 +667,7 @@ package com.Microsoft.Z3;
/** /**
* Creates a bit-vector constant. * Creates a bit-vector constant.
**/ **/
public BitVecExpr MkBVConst(String name, Integer size) public BitVecExpr MkBVConst(String name, long size)
{ {
@ -734,7 +743,7 @@ package com.Microsoft.Z3;
CheckContextMatch(args); CheckContextMatch(args);
return new BoolExpr(this, Native.mkDistinct(nCtx, (Integer)args.Length, AST.ArrayToNative(args))); return new BoolExpr(this, Native.mkDistinct(nCtx, (long)args.Length, AST.ArrayToNative(args)));
} }
/** /**
@ -820,7 +829,7 @@ package com.Microsoft.Z3;
CheckContextMatch(t); CheckContextMatch(t);
return new BoolExpr(this, Native.mkAnd(nCtx, (Integer)t.Length, AST.ArrayToNative(t))); return new BoolExpr(this, Native.mkAnd(nCtx, (long)t.Length, AST.ArrayToNative(t)));
} }
/** /**
@ -833,7 +842,7 @@ package com.Microsoft.Z3;
CheckContextMatch(t); CheckContextMatch(t);
return new BoolExpr(this, Native.mkOr(nCtx, (Integer)t.Length, AST.ArrayToNative(t))); return new BoolExpr(this, Native.mkOr(nCtx, (long)t.Length, AST.ArrayToNative(t)));
} }
/** /**
@ -846,7 +855,7 @@ package com.Microsoft.Z3;
CheckContextMatch(t); CheckContextMatch(t);
return (ArithExpr)Expr.Create(this, Native.mkAdd(nCtx, (Integer)t.Length, AST.ArrayToNative(t))); return (ArithExpr)Expr.Create(this, Native.mkAdd(nCtx, (long)t.Length, AST.ArrayToNative(t)));
} }
/** /**
@ -859,7 +868,7 @@ package com.Microsoft.Z3;
CheckContextMatch(t); CheckContextMatch(t);
return (ArithExpr)Expr.Create(this, Native.mkMul(nCtx, (Integer)t.Length, AST.ArrayToNative(t))); return (ArithExpr)Expr.Create(this, Native.mkMul(nCtx, (long)t.Length, AST.ArrayToNative(t)));
} }
/** /**
@ -872,7 +881,7 @@ package com.Microsoft.Z3;
CheckContextMatch(t); CheckContextMatch(t);
return (ArithExpr)Expr.Create(this, Native.mkSub(nCtx, (Integer)t.Length, AST.ArrayToNative(t))); return (ArithExpr)Expr.Create(this, Native.mkSub(nCtx, (long)t.Length, AST.ArrayToNative(t)));
} }
/** /**
@ -1503,7 +1512,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkExtract(Integer high, Integer low, BitVecExpr t) public BitVecExpr MkExtract(long high, long low, BitVecExpr t)
{ {
@ -1520,7 +1529,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkSignExt(Integer i, BitVecExpr t) public BitVecExpr MkSignExt(long i, BitVecExpr t)
{ {
@ -1538,7 +1547,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkZeroExt(Integer i, BitVecExpr t) public BitVecExpr MkZeroExt(long i, BitVecExpr t)
{ {
@ -1553,7 +1562,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkRepeat(Integer i, BitVecExpr t) public BitVecExpr MkRepeat(long i, BitVecExpr t)
{ {
@ -1640,7 +1649,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkBVRotateLeft(Integer i, BitVecExpr t) public BitVecExpr MkBVRotateLeft(long i, BitVecExpr t)
{ {
@ -1656,7 +1665,7 @@ package com.Microsoft.Z3;
* The argument <paramref name="t"/> must have a bit-vector sort. * The argument <paramref name="t"/> must have a bit-vector sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkBVRotateRight(Integer i, BitVecExpr t) public BitVecExpr MkBVRotateRight(long i, BitVecExpr t)
{ {
@ -1711,7 +1720,7 @@ package com.Microsoft.Z3;
* The argument must be of integer sort. * The argument must be of integer sort.
* </remarks> * </remarks>
**/ **/
public BitVecExpr MkInt2BV(Integer n, IntExpr t) public BitVecExpr MkInt2BV(long n, IntExpr t)
{ {
@ -2089,7 +2098,7 @@ package com.Microsoft.Z3;
CheckContextMatch(args); CheckContextMatch(args);
return Expr.Create(this, Native.mkSetUnion(nCtx, (Integer)args.Length, AST.ArrayToNative(args))); return Expr.Create(this, Native.mkSetUnion(nCtx, (long)args.Length, AST.ArrayToNative(args)));
} }
/** /**
@ -2102,7 +2111,7 @@ package com.Microsoft.Z3;
CheckContextMatch(args); CheckContextMatch(args);
return Expr.Create(this, Native.mkSetIntersect(nCtx, (Integer)args.Length, AST.ArrayToNative(args))); return Expr.Create(this, Native.mkSetIntersect(nCtx, (long)args.Length, AST.ArrayToNative(args)));
} }
/** /**
@ -2198,7 +2207,7 @@ package com.Microsoft.Z3;
* <param name="ty">Sort of the numeral</param> * <param name="ty">Sort of the numeral</param>
* @return A Term with value <paramref name="v"/> and type <paramref name="ty"/> * @return A Term with value <paramref name="v"/> and type <paramref name="ty"/>
**/ **/
public Expr MkNumeral(Integer v, Sort ty) public Expr MkNumeral(long v, Sort ty)
{ {
@ -2286,7 +2295,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* @return A Term with value <paramref name="v"/> and sort Real * @return A Term with value <paramref name="v"/> and sort Real
**/ **/
public RatNum MkReal(Integer v) public RatNum MkReal(long v)
{ {
@ -2345,7 +2354,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* @return A Term with value <paramref name="v"/> and sort Integer * @return A Term with value <paramref name="v"/> and sort Integer
**/ **/
public IntNum MkInt(Integer v) public IntNum MkInt(long v)
{ {
@ -2381,7 +2390,7 @@ package com.Microsoft.Z3;
* <param name="v">A string representing the value in decimal notation.</param> * <param name="v">A string representing the value in decimal notation.</param>
* <param name="size">the size of the bit-vector</param> * <param name="size">the size of the bit-vector</param>
**/ **/
public BitVecNum MkBV(String v, Integer size) public BitVecNum MkBV(String v, long size)
{ {
@ -2393,7 +2402,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* <param name="size">the size of the bit-vector</param> * <param name="size">the size of the bit-vector</param>
**/ **/
public BitVecNum MkBV(int v, Integer size) public BitVecNum MkBV(int v, long size)
{ {
@ -2405,7 +2414,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* <param name="size">the size of the bit-vector</param> * <param name="size">the size of the bit-vector</param>
**/ **/
public BitVecNum MkBV(Integer v, Integer size) public BitVecNum MkBV(long v, long size)
{ {
@ -2417,7 +2426,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* * <param name="size">the size of the bit-vector</param> * * <param name="size">the size of the bit-vector</param>
**/ **/
public BitVecNum MkBV(long v, Integer size) public BitVecNum MkBV(long v, long size)
{ {
@ -2429,7 +2438,7 @@ package com.Microsoft.Z3;
* <param name="v">value of the numeral.</param> * <param name="v">value of the numeral.</param>
* <param name="size">the size of the bit-vector</param> * <param name="size">the size of the bit-vector</param>
**/ **/
public BitVecNum MkBV(ulong v, Integer size) public BitVecNum MkBV(ulong v, long size)
{ {
@ -2456,7 +2465,7 @@ package com.Microsoft.Z3;
* <param name="quantifierID">optional symbol to track quantifier.</param> * <param name="quantifierID">optional symbol to track quantifier.</param>
* <param name="skolemID">optional symbol to track skolem constants.</param> * <param name="skolemID">optional symbol to track skolem constants.</param>
**/ **/
public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2476,7 +2485,7 @@ package com.Microsoft.Z3;
/** /**
* Create a universal Quantifier. * Create a universal Quantifier.
**/ **/
public Quantifier MkForall(Expr[] boundConstants, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkForall(Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2492,7 +2501,7 @@ package com.Microsoft.Z3;
* Create an existential Quantifier. * Create an existential Quantifier.
* <seealso cref="MkForall(Sort[],Symbol[],Expr,uint,Pattern[],Expr[],Symbol,Symbol)"/> * <seealso cref="MkForall(Sort[],Symbol[],Expr,uint,Pattern[],Expr[],Symbol,Symbol)"/>
**/ **/
public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2510,7 +2519,7 @@ package com.Microsoft.Z3;
/** /**
* Create an existential Quantifier. * Create an existential Quantifier.
**/ **/
public Quantifier MkExists(Expr[] boundConstants, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkExists(Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2525,7 +2534,7 @@ package com.Microsoft.Z3;
/** /**
* Create a Quantifier. * Create a Quantifier.
**/ **/
public Quantifier MkQuantifier(boolean universal, Sort[] sorts, Symbol[] names, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkQuantifier(boolean universal, Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2548,7 +2557,7 @@ package com.Microsoft.Z3;
/** /**
* Create a Quantifier. * Create a Quantifier.
**/ **/
public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, Expr body, Integer weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID)
{ {
@ -2581,7 +2590,7 @@ package com.Microsoft.Z3;
* <seealso cref="FuncDecl.ToString()"/> * <seealso cref="FuncDecl.ToString()"/>
* <seealso cref="Sort.ToString()"/> * <seealso cref="Sort.ToString()"/>
**/ **/
public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx, Integer(value)); } public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx, (long)value); }
/** /**
* Convert a benchmark into an SMT-LIB formatted string. * Convert a benchmark into an SMT-LIB formatted string.
@ -2601,7 +2610,7 @@ package com.Microsoft.Z3;
return Native.benchmarkToSmtlibString(nCtx, name, logic, status, attributes, return Native.benchmarkToSmtlibString(nCtx, name, logic, status, attributes,
(Integer)assumptions.Length, AST.ArrayToNative(assumptions), (long)assumptions.Length, AST.ArrayToNative(assumptions),
formula.NativeObject); formula.NativeObject);
} }
@ -2617,10 +2626,10 @@ package com.Microsoft.Z3;
**/ **/
public void ParseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) public void ParseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls)
{ {
Integer csn = Symbol.ArrayLength(sortNames); long csn = Symbol.ArrayLength(sortNames);
Integer cs = Sort.ArrayLength(sorts); long cs = Sort.ArrayLength(sorts);
Integer cdn = Symbol.ArrayLength(declNames); long cdn = Symbol.ArrayLength(declNames);
Integer cd = AST.ArrayLength(decls); long cd = AST.ArrayLength(decls);
if (csn != cs || cdn != cd) if (csn != cs || cdn != cd)
throw new Z3Exception("Argument size mismatch"); throw new Z3Exception("Argument size mismatch");
Native.parseSmtlibString(nCtx, str, Native.parseSmtlibString(nCtx, str,
@ -2634,10 +2643,10 @@ package com.Microsoft.Z3;
**/ **/
public void ParseSMTLIBFile(String fileName, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) public void ParseSMTLIBFile(String fileName, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls)
{ {
Integer csn = Symbol.ArrayLength(sortNames); long csn = Symbol.ArrayLength(sortNames);
Integer cs = Sort.ArrayLength(sorts); long cs = Sort.ArrayLength(sorts);
Integer cdn = Symbol.ArrayLength(declNames); long cdn = Symbol.ArrayLength(declNames);
Integer cd = AST.ArrayLength(decls); long cd = AST.ArrayLength(decls);
if (csn != cs || cdn != cd) if (csn != cs || cdn != cd)
throw new Z3Exception("Argument size mismatch"); throw new Z3Exception("Argument size mismatch");
Native.parseSmtlibFile(nCtx, fileName, Native.parseSmtlibFile(nCtx, fileName,
@ -2648,7 +2657,7 @@ package com.Microsoft.Z3;
/** /**
* The number of SMTLIB formulas parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The number of SMTLIB formulas parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
**/ **/
public Integer NumSMTLIBFormulas () { return Native.getSmtlibNumFormulas(nCtx); } public long NumSMTLIBFormulas () { return Native.getSmtlibNumFormulas(nCtx); }
/** /**
* The formulas parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The formulas parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
@ -2657,9 +2666,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumSMTLIBFormulas; long n = NumSMTLIBFormulas;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibFormula(nCtx, i)); res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibFormula(nCtx, i));
return res; return res;
} }
@ -2667,7 +2676,7 @@ package com.Microsoft.Z3;
/** /**
* The number of SMTLIB assumptions parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The number of SMTLIB assumptions parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
**/ **/
public Integer NumSMTLIBAssumptions () { return Native.getSmtlibNumAssumptions(nCtx); } public long NumSMTLIBAssumptions () { return Native.getSmtlibNumAssumptions(nCtx); }
/** /**
* The assumptions parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The assumptions parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
@ -2676,9 +2685,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumSMTLIBAssumptions; long n = NumSMTLIBAssumptions;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibAssumption(nCtx, i)); res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibAssumption(nCtx, i));
return res; return res;
} }
@ -2686,7 +2695,7 @@ package com.Microsoft.Z3;
/** /**
* The number of SMTLIB declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The number of SMTLIB declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
**/ **/
public Integer NumSMTLIBDecls () { return Native.getSmtlibNumDecls(nCtx); } public long NumSMTLIBDecls () { return Native.getSmtlibNumDecls(nCtx); }
/** /**
* The declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
@ -2695,9 +2704,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumSMTLIBDecls; long n = NumSMTLIBDecls;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx, i)); res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx, i));
return res; return res;
} }
@ -2705,7 +2714,7 @@ package com.Microsoft.Z3;
/** /**
* The number of SMTLIB sorts parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The number of SMTLIB sorts parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
**/ **/
public Integer NumSMTLIBSorts () { return Native.getSmtlibNumSorts(nCtx); } public long NumSMTLIBSorts () { return Native.getSmtlibNumSorts(nCtx); }
/** /**
* The declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>. * The declarations parsed by the last call to <code>ParseSMTLIBString</code> or <code>ParseSMTLIBFile</code>.
@ -2714,9 +2723,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumSMTLIBSorts; long n = NumSMTLIBSorts;
Sort[] res = new Sort[n]; Sort[] res = new Sort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx, i)); res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx, i));
return res; return res;
} }
@ -2730,10 +2739,10 @@ package com.Microsoft.Z3;
{ {
Integer csn = Symbol.ArrayLength(sortNames); long csn = Symbol.ArrayLength(sortNames);
Integer cs = Sort.ArrayLength(sorts); long cs = Sort.ArrayLength(sorts);
Integer cdn = Symbol.ArrayLength(declNames); long cdn = Symbol.ArrayLength(declNames);
Integer cd = AST.ArrayLength(decls); long cd = AST.ArrayLength(decls);
if (csn != cs || cdn != cd) if (csn != cs || cdn != cd)
throw new Z3Exception("Argument size mismatch"); throw new Z3Exception("Argument size mismatch");
return (BoolExpr)Expr.Create(this, Native.parseSmtlib2String(nCtx, str, return (BoolExpr)Expr.Create(this, Native.parseSmtlib2String(nCtx, str,
@ -2749,10 +2758,10 @@ package com.Microsoft.Z3;
{ {
Integer csn = Symbol.ArrayLength(sortNames); long csn = Symbol.ArrayLength(sortNames);
Integer cs = Sort.ArrayLength(sorts); long cs = Sort.ArrayLength(sorts);
Integer cdn = Symbol.ArrayLength(declNames); long cdn = Symbol.ArrayLength(declNames);
Integer cd = AST.ArrayLength(decls); long cd = AST.ArrayLength(decls);
if (csn != cs || cdn != cd) if (csn != cs || cdn != cd)
throw new Z3Exception("Argument size mismatch"); throw new Z3Exception("Argument size mismatch");
return (BoolExpr)Expr.Create(this, Native.parseSmtlib2File(nCtx, fileName, return (BoolExpr)Expr.Create(this, Native.parseSmtlib2File(nCtx, fileName,
@ -2790,7 +2799,7 @@ package com.Microsoft.Z3;
/** /**
* The number of supported tactics. * The number of supported tactics.
**/ **/
public Integer NumTactics() { return Native.getNumTactics(nCtx); } public long NumTactics() { return Native.getNumTactics(nCtx); }
/** /**
* The names of all supported tactics. * The names of all supported tactics.
@ -2799,9 +2808,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumTactics; long n = NumTactics;
String[] res = new String[n]; String[] res = new String[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Native.getTacticName(nCtx, i); res[i] = Native.getTacticName(nCtx, i);
return res; return res;
} }
@ -2896,7 +2905,7 @@ package com.Microsoft.Z3;
* If <paramref name="t"/> does not terminate within <paramref name="ms"/> milliseconds, then it fails. * If <paramref name="t"/> does not terminate within <paramref name="ms"/> milliseconds, then it fails.
* </remarks> * </remarks>
**/ **/
public Tactic TryFor(Tactic t, Integer ms) public Tactic TryFor(Tactic t, long ms)
{ {
@ -2944,7 +2953,7 @@ package com.Microsoft.Z3;
* Create a tactic that keeps applying <paramref name="t"/> until the goal is not * Create a tactic that keeps applying <paramref name="t"/> until the goal is not
* modified anymore or the maximum number of iterations <paramref name="max"/> is reached. * modified anymore or the maximum number of iterations <paramref name="max"/> is reached.
**/ **/
public Tactic Repeat(Tactic t, Integer max) public Tactic Repeat(Tactic t, long max)
{ {
@ -3062,7 +3071,7 @@ package com.Microsoft.Z3;
/** /**
* The number of supported Probes. * The number of supported Probes.
**/ **/
public Integer NumProbes() { return Native.getNumProbes(nCtx); } public long NumProbes() { return Native.getNumProbes(nCtx); }
/** /**
* The names of all supported Probes. * The names of all supported Probes.
@ -3071,9 +3080,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumProbes; long n = NumProbes;
String[] res = new String[n]; String[] res = new String[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Native.getProbeName(nCtx, i); res[i] = Native.getProbeName(nCtx, i);
return res; return res;
} }
@ -3355,7 +3364,7 @@ package com.Microsoft.Z3;
///// Note that it is possible for memory leaks to occur if error handlers ///// Note that it is possible for memory leaks to occur if error handlers
///// throw exceptions. ///// throw exceptions.
///// </remarks> ///// </remarks>
//public delegate void ErrorHandler(Context ctx, Z3ErrorCode errorCode, String errorString); //public delegate void ErrorHandler(Context ctx, Z3_error_code errorCode, String errorString);
///// <summary> ///// <summary>
///// The OnError event. ///// The OnError event.
@ -3386,29 +3395,29 @@ package com.Microsoft.Z3;
**/ **/
public String GetParamValue(String id) public String GetParamValue(String id)
{ {
IntPtr res = IntPtr.Zero; Native.IntPtr res = new Native.IntPtr();
int r = Native.getParamValue(nCtx, id, out res); int r = Native.getParamValue(nCtx, id, res);
if (r == (int)Z3Lboolean.Z3LFALSE) if (r == (int)Z3_lboolean.Z3_L_FALSE)
return null; return null;
else else
return Marshal.PtrtoStringAnsi(res); return Marshal.PtrtoStringAnsi(res);
} }
IntPtr mCtx = IntPtr.Zero; IntPtr m_ctx = IntPtr.Zero;
Native.errorHandler mNErrHandler = null; Native.errorHandler mNErrHandler = null;
IntPtr nCtx () { return mCtx; } IntPtr nCtx () { return m_ctx; }
void NativeErrorHandler(IntPtr ctx, Z3ErrorCode errorCode) void NativeErrorHandler(IntPtr ctx, Z3_error_code errorCode)
{ {
// Do-nothing error handler. The wrappers in Z3.Native will throw exceptions upon errors. // Do-nothing error handler. The wrappers in Z3.Native will throw exceptions upon errors.
} }
void InitContext() void InitContext()
{ {
PrintMode = Z3AstPrintMode.Z3PRINTSMTLIB2COMPLIANT; PrintMode = Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT;
mNErrHandler = new Native.errorHandler(NativeErrorHandler); // keep reference so it doesn't get collected. m_n_err_handler = new Native.errorHandler(NativeErrorHandler); // keep reference so it doesn't get collected.
Native.setErrorHandler(mCtx, mNErrHandler); Native.setErrorHandler(m_ctx, m_n_err_handler);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
@ -3453,40 +3462,40 @@ package com.Microsoft.Z3;
} }
private AST.DecRefQueue mASTDRQ = new AST.DecRefQueue(); private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
private ASTMap.DecRefQueue mASTMapDRQ = new ASTMap.DecRefQueue(); private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue();
private ASTVector.DecRefQueue mASTVectorDRQ = new ASTVector.DecRefQueue(); private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue();
private ApplyResult.DecRefQueue mApplyResultDRQ = new ApplyResult.DecRefQueue(); private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue();
private FuncInterp.Entry.DecRefQueue mFuncEntryDRQ = new FuncInterp.Entry.DecRefQueue(); private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue();
private FuncInterp.DecRefQueue mFuncInterpDRQ = new FuncInterp.DecRefQueue(); private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue();
private Goal.DecRefQueue mGoalDRQ = new Goal.DecRefQueue(); private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue();
private Model.DecRefQueue mModelDRQ = new Model.DecRefQueue(); private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue();
private Params.DecRefQueue mParamsDRQ = new Params.DecRefQueue(); private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue();
private ParamDescrs.DecRefQueue mParamDescrsDRQ = new ParamDescrs.DecRefQueue(); private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue();
private Probe.DecRefQueue mProbeDRQ = new Probe.DecRefQueue(); private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue();
private Solver.DecRefQueue mSolverDRQ = new Solver.DecRefQueue(); private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue();
private Statistics.DecRefQueue mStatisticsDRQ = new Statistics.DecRefQueue(); private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue();
private Tactic.DecRefQueue mTacticDRQ = new Tactic.DecRefQueue(); private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue();
private Fixedpoint.DecRefQueue mFixedpointDRQ = new Fixedpoint.DecRefQueue(); private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue();
AST.DecRefQueue AST_DRQ () { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return mASTDRQ; } AST.DecRefQueue AST_DRQ () { return m_AST_DRQ; }
ASTMap.DecRefQueue ASTMap_DRQ () { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return mASTMapDRQ; } ASTMap.DecRefQueue ASTMap_DRQ () { return m_ASTMap_DRQ; }
ASTVector.DecRefQueue ASTVector_DRQ () { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return mASTVectorDRQ; } ASTVector.DecRefQueue ASTVector_DRQ () { return m_ASTVector_DRQ; }
ApplyResult.DecRefQueue ApplyResult_DRQ () { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return mApplyResultDRQ; } ApplyResult.DecRefQueue ApplyResult_DRQ () { return m_ApplyResult_DRQ; }
FuncInterp.Entry.DecRefQueue FuncEntry_DRQ () { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return mFuncEntryDRQ; } FuncInterp.Entry.DecRefQueue FuncEntry_DRQ () { return m_FuncEntry_DRQ; }
FuncInterp.DecRefQueue FuncInterp_DRQ () { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return mFuncInterpDRQ; } FuncInterp.DecRefQueue FuncInterp_DRQ () { return m_FuncInterp_DRQ; }
Goal.DecRefQueue Goal_DRQ () { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return mGoalDRQ; } Goal.DecRefQueue Goal_DRQ () { return m_Goal_DRQ; }
Model.DecRefQueue Model_DRQ () { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return mModelDRQ; } Model.DecRefQueue Model_DRQ () { return m_Model_DRQ; }
Params.DecRefQueue Params_DRQ () { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return mParamsDRQ; } Params.DecRefQueue Params_DRQ () { return m_Params_DRQ; }
ParamDescrs.DecRefQueue ParamDescrs_DRQ () { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return mParamDescrsDRQ; } ParamDescrs.DecRefQueue ParamDescrs_DRQ () { return m_ParamDescrs_DRQ; }
Probe.DecRefQueue Probe_DRQ () { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return mProbeDRQ; } Probe.DecRefQueue Probe_DRQ () { return m_Probe_DRQ; }
Solver.DecRefQueue Solver_DRQ () { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return mSolverDRQ; } Solver.DecRefQueue Solver_DRQ () { return m_Solver_DRQ; }
Statistics.DecRefQueue Statistics_DRQ () { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return mStatisticsDRQ; } Statistics.DecRefQueue Statistics_DRQ () { return m_Statistics_DRQ; }
Tactic.DecRefQueue Tactic_DRQ () { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return mTacticDRQ; } Tactic.DecRefQueue Tactic_DRQ () { return m_Tactic_DRQ; }
Fixedpoint.DecRefQueue Fixedpoint_DRQ () { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return mFixedpointDRQ; } Fixedpoint.DecRefQueue Fixedpoint_DRQ () { return m_Fixedpoint_DRQ; }
Integer refCount = 0; long refCount = 0;
/** /**
* Finalizer. * Finalizer.
@ -3498,9 +3507,9 @@ package com.Microsoft.Z3;
if (refCount == 0) if (refCount == 0)
{ {
mNErrHandler = null; m_n_err_handler = null;
Native.delContext(mCtx); Native.delContext(m_ctx);
mCtx = IntPtr.Zero; m_ctx = IntPtr.Zero;
} }
else else
GC.ReRegisterForFinalize(this); GC.ReRegisterForFinalize(this);
@ -3512,23 +3521,23 @@ package com.Microsoft.Z3;
public void Dispose() public void Dispose()
{ {
// Console.WriteLine("Context Dispose from " + System.Threading.Thread.CurrentThread.ManagedThreadId); // Console.WriteLine("Context Dispose from " + System.Threading.Thread.CurrentThread.ManagedThreadId);
ASTDRQ.Clear(this); AST_DRQ.Clear(this);
ASTMapDRQ.Clear(this); ASTMap_DRQ.Clear(this);
ASTVectorDRQ.Clear(this); ASTVector_DRQ.Clear(this);
ApplyResultDRQ.Clear(this); ApplyResult_DRQ.Clear(this);
FuncEntryDRQ.Clear(this); FuncEntry_DRQ.Clear(this);
FuncInterpDRQ.Clear(this); FuncInterp_DRQ.Clear(this);
GoalDRQ.Clear(this); Goal_DRQ.Clear(this);
ModelDRQ.Clear(this); Model_DRQ.Clear(this);
ParamsDRQ.Clear(this); Params_DRQ.Clear(this);
ProbeDRQ.Clear(this); Probe_DRQ.Clear(this);
SolverDRQ.Clear(this); Solver_DRQ.Clear(this);
StatisticsDRQ.Clear(this); Statistics_DRQ.Clear(this);
TacticDRQ.Clear(this); Tactic_DRQ.Clear(this);
FixedpointDRQ.Clear(this); Fixedpoint_DRQ.Clear(this);
mBooleanSort = null; m_booleanSort = null;
mIntSort = null; m_intSort = null;
mRealSort = null; m_realSort = null;
} }
} }

View file

@ -10,41 +10,61 @@ package com.Microsoft.Z3;
/* using System.Threading; */ /* using System.Threading; */
abstract class DecRefQueue abstract class DecRefQueue
{
private void ObjectInvariant() private void ObjectInvariant()
{
}
protected Object m_lock = new Object();
readonly protected Object mLock = new Object(); protected List<IntPtr> m_queue = new List<IntPtr>();
readonly protected List<IntPtr> mQueue = new List<IntPtr>(); final long m_move_limit = 1024;
const Integer mMoveLimit = 1024;
public abstract void IncRef(Context ctx, IntPtr obj); public abstract void IncRef(Context ctx, IntPtr obj);
public abstract void DecRef(Context ctx, IntPtr obj); public abstract void DecRef(Context ctx, IntPtr obj);
public void IncAndClear(Context ctx, IntPtr o) public void IncAndClear(Context ctx, IntPtr o)
{
IncRef(ctx, o); IncRef(ctx, o);
if (mQueue.Count >= mMoveLimit) Clear(ctx); if (m_queue.Count >= m_move_limit) Clear(ctx);
}
public void Add(IntPtr o) public void Add(IntPtr o)
{
if (o == IntPtr.Zero) return; if (o == IntPtr.Zero) return;
lock (mLock) synchronized (m_lock)
mQueue.Add(o); {
m_queue.Add(o);
}
}
public void Clear(Context ctx) public void Clear(Context ctx)
{
lock (mLock) synchronized (m_lock)
for (IntPtr.Iterator o = mQueue.iterator(); o.hasNext(); ) {
for (IntPtr.Iterator o = m_queue.iterator(); o.hasNext(); )
DecRef(ctx, o); DecRef(ctx, o);
mQueue.Clear(); m_queue.Clear();
}
}
}
abstract class DecRefQueueContracts : DecRefQueue abstract class DecRefQueueContracts extends DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj) public void IncRef(Context ctx, IntPtr obj)
{
}
public void DecRef(Context ctx, IntPtr obj) public void DecRef(Context ctx, IntPtr obj)
{
}
}

View file

@ -0,0 +1,19 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_ast_kind
**/
public enum Z3_ast_kind {
Z3_VAR_AST (2),
Z3_SORT_AST (4),
Z3_QUANTIFIER_AST (3),
Z3_UNKNOWN_AST (1000),
Z3_FUNC_DECL_AST (5),
Z3_NUMERAL_AST (0),
Z3_APP_AST (1),
}

View file

@ -0,0 +1,16 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_ast_print_mode
**/
public enum Z3_ast_print_mode {
Z3_PRINT_SMTLIB2_COMPLIANT (3),
Z3_PRINT_SMTLIB_COMPLIANT (2),
Z3_PRINT_SMTLIB_FULL (0),
Z3_PRINT_LOW_LEVEL (1),
}

View file

@ -0,0 +1,164 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_decl_kind
**/
public enum Z3_decl_kind {
Z3_OP_LABEL (1792),
Z3_OP_PR_REWRITE (1294),
Z3_OP_UNINTERPRETED (2051),
Z3_OP_SUB (519),
Z3_OP_ZERO_EXT (1058),
Z3_OP_ADD (518),
Z3_OP_IS_INT (528),
Z3_OP_BREDOR (1061),
Z3_OP_BNOT (1051),
Z3_OP_BNOR (1054),
Z3_OP_PR_CNF_STAR (1315),
Z3_OP_RA_JOIN (1539),
Z3_OP_LE (514),
Z3_OP_SET_UNION (773),
Z3_OP_PR_UNDEF (1280),
Z3_OP_BREDAND (1062),
Z3_OP_LT (516),
Z3_OP_RA_UNION (1540),
Z3_OP_BADD (1028),
Z3_OP_BUREM0 (1039),
Z3_OP_OEQ (267),
Z3_OP_PR_MODUS_PONENS (1284),
Z3_OP_RA_CLONE (1548),
Z3_OP_REPEAT (1060),
Z3_OP_RA_NEGATION_FILTER (1544),
Z3_OP_BSMOD0 (1040),
Z3_OP_BLSHR (1065),
Z3_OP_BASHR (1066),
Z3_OP_PR_UNIT_RESOLUTION (1304),
Z3_OP_ROTATE_RIGHT (1068),
Z3_OP_ARRAY_DEFAULT (772),
Z3_OP_PR_PULL_QUANT (1296),
Z3_OP_PR_APPLY_DEF (1310),
Z3_OP_PR_REWRITE_STAR (1295),
Z3_OP_IDIV (523),
Z3_OP_PR_GOAL (1283),
Z3_OP_PR_IFF_TRUE (1305),
Z3_OP_LABEL_LIT (1793),
Z3_OP_BOR (1050),
Z3_OP_PR_SYMMETRY (1286),
Z3_OP_TRUE (256),
Z3_OP_SET_COMPLEMENT (776),
Z3_OP_CONCAT (1056),
Z3_OP_PR_NOT_OR_ELIM (1293),
Z3_OP_IFF (263),
Z3_OP_BSHL (1064),
Z3_OP_PR_TRANSITIVITY (1287),
Z3_OP_SGT (1048),
Z3_OP_RA_WIDEN (1541),
Z3_OP_PR_DEF_INTRO (1309),
Z3_OP_NOT (265),
Z3_OP_PR_QUANT_INTRO (1290),
Z3_OP_UGT (1047),
Z3_OP_DT_RECOGNISER (2049),
Z3_OP_SET_INTERSECT (774),
Z3_OP_BSREM (1033),
Z3_OP_RA_STORE (1536),
Z3_OP_SLT (1046),
Z3_OP_ROTATE_LEFT (1067),
Z3_OP_PR_NNF_NEG (1313),
Z3_OP_PR_REFLEXIVITY (1285),
Z3_OP_ULEQ (1041),
Z3_OP_BIT1 (1025),
Z3_OP_BIT0 (1026),
Z3_OP_EQ (258),
Z3_OP_BMUL (1030),
Z3_OP_ARRAY_MAP (771),
Z3_OP_STORE (768),
Z3_OP_PR_HYPOTHESIS (1302),
Z3_OP_RA_RENAME (1545),
Z3_OP_AND (261),
Z3_OP_TO_REAL (526),
Z3_OP_PR_NNF_POS (1312),
Z3_OP_PR_AND_ELIM (1292),
Z3_OP_MOD (525),
Z3_OP_BUDIV0 (1037),
Z3_OP_PR_TRUE (1281),
Z3_OP_BNAND (1053),
Z3_OP_PR_ELIM_UNUSED_VARS (1299),
Z3_OP_RA_FILTER (1543),
Z3_OP_FD_LT (1549),
Z3_OP_RA_EMPTY (1537),
Z3_OP_DIV (522),
Z3_OP_ANUM (512),
Z3_OP_MUL (521),
Z3_OP_UGEQ (1043),
Z3_OP_BSREM0 (1038),
Z3_OP_PR_TH_LEMMA (1318),
Z3_OP_BXOR (1052),
Z3_OP_DISTINCT (259),
Z3_OP_PR_IFF_FALSE (1306),
Z3_OP_BV2INT (1072),
Z3_OP_EXT_ROTATE_LEFT (1069),
Z3_OP_PR_PULL_QUANT_STAR (1297),
Z3_OP_BSUB (1029),
Z3_OP_PR_ASSERTED (1282),
Z3_OP_BXNOR (1055),
Z3_OP_EXTRACT (1059),
Z3_OP_PR_DER (1300),
Z3_OP_DT_CONSTRUCTOR (2048),
Z3_OP_GT (517),
Z3_OP_BUREM (1034),
Z3_OP_IMPLIES (266),
Z3_OP_SLEQ (1042),
Z3_OP_GE (515),
Z3_OP_BAND (1049),
Z3_OP_ITE (260),
Z3_OP_AS_ARRAY (778),
Z3_OP_RA_SELECT (1547),
Z3_OP_CONST_ARRAY (770),
Z3_OP_BSDIV (1031),
Z3_OP_OR (262),
Z3_OP_PR_HYPER_RESOLVE (1319),
Z3_OP_AGNUM (513),
Z3_OP_PR_PUSH_QUANT (1298),
Z3_OP_BSMOD (1035),
Z3_OP_PR_IFF_OEQ (1311),
Z3_OP_PR_LEMMA (1303),
Z3_OP_SET_SUBSET (777),
Z3_OP_SELECT (769),
Z3_OP_RA_PROJECT (1542),
Z3_OP_BNEG (1027),
Z3_OP_UMINUS (520),
Z3_OP_REM (524),
Z3_OP_TO_INT (527),
Z3_OP_PR_QUANT_INST (1301),
Z3_OP_SGEQ (1044),
Z3_OP_POWER (529),
Z3_OP_XOR3 (1074),
Z3_OP_RA_IS_EMPTY (1538),
Z3_OP_CARRY (1073),
Z3_OP_DT_ACCESSOR (2050),
Z3_OP_PR_TRANSITIVITY_STAR (1288),
Z3_OP_PR_NNF_STAR (1314),
Z3_OP_PR_COMMUTATIVITY (1307),
Z3_OP_ULT (1045),
Z3_OP_BSDIV0 (1036),
Z3_OP_SET_DIFFERENCE (775),
Z3_OP_INT2BV (1071),
Z3_OP_XOR (264),
Z3_OP_PR_MODUS_PONENS_OEQ (1317),
Z3_OP_BNUM (1024),
Z3_OP_BUDIV (1032),
Z3_OP_PR_MONOTONICITY (1289),
Z3_OP_PR_DEF_AXIOM (1308),
Z3_OP_FALSE (257),
Z3_OP_EXT_ROTATE_RIGHT (1070),
Z3_OP_PR_DISTRIBUTIVITY (1291),
Z3_OP_SIGN_EXT (1057),
Z3_OP_PR_SKOLEMIZE (1316),
Z3_OP_BCOMP (1063),
Z3_OP_RA_COMPLEMENT (1546),
}

View file

@ -0,0 +1,25 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_error_code
**/
public enum Z3_error_code {
Z3_INVALID_PATTERN (6),
Z3_MEMOUT_FAIL (7),
Z3_NO_PARSER (5),
Z3_OK (0),
Z3_INVALID_ARG (3),
Z3_EXCEPTION (12),
Z3_IOB (2),
Z3_INTERNAL_FATAL (9),
Z3_INVALID_USAGE (10),
Z3_FILE_ACCESS_ERROR (8),
Z3_SORT_ERROR (1),
Z3_PARSER_ERROR (4),
Z3_DEC_REF_ERROR (11),
}

View file

@ -0,0 +1,16 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_goal_prec
**/
public enum Z3_goal_prec {
Z3_GOAL_UNDER (1),
Z3_GOAL_PRECISE (0),
Z3_GOAL_UNDER_OVER (3),
Z3_GOAL_OVER (2),
}

View file

@ -0,0 +1,15 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_lbool
**/
public enum Z3_lbool {
Z3_L_TRUE (1),
Z3_L_UNDEF (0),
Z3_L_FALSE (-1),
}

View file

@ -0,0 +1,19 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_param_kind
**/
public enum Z3_param_kind {
Z3_PK_BOOL (1),
Z3_PK_SYMBOL (3),
Z3_PK_OTHER (5),
Z3_PK_INVALID (6),
Z3_PK_UINT (0),
Z3_PK_STRING (4),
Z3_PK_DOUBLE (2),
}

View file

@ -0,0 +1,19 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_parameter_kind
**/
public enum Z3_parameter_kind {
Z3_PARAMETER_FUNC_DECL (6),
Z3_PARAMETER_DOUBLE (1),
Z3_PARAMETER_SYMBOL (3),
Z3_PARAMETER_INT (0),
Z3_PARAMETER_AST (5),
Z3_PARAMETER_SORT (4),
Z3_PARAMETER_RATIONAL (2),
}

View file

@ -0,0 +1,22 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_sort_kind
**/
public enum Z3_sort_kind {
Z3_BV_SORT (4),
Z3_FINITE_DOMAIN_SORT (8),
Z3_ARRAY_SORT (5),
Z3_UNKNOWN_SORT (1000),
Z3_RELATION_SORT (7),
Z3_REAL_SORT (3),
Z3_INT_SORT (2),
Z3_UNINTERPRETED_SORT (0),
Z3_BOOL_SORT (1),
Z3_DATATYPE_SORT (6),
}

View file

@ -0,0 +1,14 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3;
/**
* Z3_symbol_kind
**/
public enum Z3_symbol_kind {
Z3_INT_SYMBOL (0),
Z3_STRING_SYMBOL (1),
}

File diff suppressed because it is too large Load diff

View file

@ -77,13 +77,13 @@ package com.Microsoft.Z3;
/** /**
* Add table fact to the fixedpoint solver. * Add table fact to the fixedpoint solver.
**/ **/
public void AddFact(FuncDecl pred, Integer[] args) public void AddFact(FuncDecl pred, long[] args)
{ {
Context.CheckContextMatch(pred); Context.CheckContextMatch(pred);
Native.fixedpointAddFact(Context.nCtx, NativeObject, pred.NativeObject, (Integer)args.Length, args); Native.fixedpointAddFact(Context.nCtx, NativeObject, pred.NativeObject, (long)args.Length, args);
} }
/** /**
@ -97,11 +97,11 @@ package com.Microsoft.Z3;
Context.CheckContextMatch(query); Context.CheckContextMatch(query);
Z3Lboolean r = (Z3Lboolean)Native.fixedpointQuery(Context.nCtx, NativeObject, query.NativeObject); Z3_lboolean r = (Z3_lboolean)Native.fixedpointQuery(Context.nCtx, NativeObject, query.NativeObject);
switch (r) switch (r)
{ {
case Z3Lboolean.Z3LTRUE: return Status.SATISFIABLE; case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE;
case Z3Lboolean.Z3LFALSE: return Status.UNSATISFIABLE; case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE;
default: return Status.UNKNOWN; default: return Status.UNKNOWN;
} }
} }
@ -118,12 +118,12 @@ package com.Microsoft.Z3;
Context.CheckContextMatch(relations); Context.CheckContextMatch(relations);
Z3Lboolean r = (Z3Lboolean)Native.fixedpointQueryRelations(Context.nCtx, NativeObject, Z3_lboolean r = (Z3_lboolean)Native.fixedpointQueryRelations(Context.nCtx, NativeObject,
AST.ArrayLength(relations), AST.ArrayToNative(relations)); AST.ArrayLength(relations), AST.ArrayToNative(relations));
switch (r) switch (r)
{ {
case Z3Lboolean.Z3LTRUE: return Status.SATISFIABLE; case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE;
case Z3Lboolean.Z3LFALSE: return Status.UNSATISFIABLE; case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE;
default: return Status.UNKNOWN; default: return Status.UNKNOWN;
} }
} }
@ -182,7 +182,7 @@ package com.Microsoft.Z3;
/** /**
* Retrieve the number of levels explored for a given predicate. * Retrieve the number of levels explored for a given predicate.
**/ **/
public Integer GetNumLevels(FuncDecl predicate) public long GetNumLevels(FuncDecl predicate)
{ {
return Native.fixedpointGetNumLevels(Context.nCtx, NativeObject, predicate.NativeObject); return Native.fixedpointGetNumLevels(Context.nCtx, NativeObject, predicate.NativeObject);
} }
@ -238,13 +238,14 @@ package com.Microsoft.Z3;
/** /**
* Retrieve set of rules added to fixedpoint context. * Retrieve set of rules added to fixedpoint context.
**/ **/
public BoolExpr[] Rules {() public BoolExpr[] Rules()
{
ASTVector v = new ASTVector(Context, Native.fixedpointGetRules(Context.nCtx, NativeObject)); ASTVector v = new ASTVector(Context, Native.fixedpointGetRules(Context.nCtx, NativeObject));
Integer n = v.Size; long n = v.Size;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject); res[i] = new BoolExpr(Context, v[i].NativeObject);
return res; return res;
} }
@ -252,13 +253,14 @@ package com.Microsoft.Z3;
/** /**
* Retrieve set of assertions added to fixedpoint context. * Retrieve set of assertions added to fixedpoint context.
**/ **/
public BoolExpr[] Assertions {() public BoolExpr[] Assertions()
{
ASTVector v = new ASTVector(Context, Native.fixedpointGetAssertions(Context.nCtx, NativeObject)); ASTVector v = new ASTVector(Context, Native.fixedpointGetAssertions(Context.nCtx, NativeObject));
Integer n = v.Size; long n = v.Size;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject); res[i] = new BoolExpr(Context, v[i].NativeObject);
return res; return res;
} }
@ -288,13 +290,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.FixedpointDRQ.IncAndClear(Context, o); Context.Fixedpoint_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.FixedpointDRQ.Add(o); Context.Fixedpoint_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -28,7 +28,7 @@ package com.Microsoft.Z3;
**/ **/
public boolean Equals(object o) public boolean Equals(object o)
{ {
FuncDecl casted = o as FuncDecl; FuncDecl casted = (FuncDecl) o;
if (casted == null) return false; if (casted == null) return false;
return this == casted; return this == casted;
} }
@ -52,18 +52,18 @@ package com.Microsoft.Z3;
/** /**
* Returns a unique identifier for the function declaration. * Returns a unique identifier for the function declaration.
**/ **/
new public Integer Id() { return Native.getFuncDeclId(Context.nCtx, NativeObject); } public long Id() { return Native.getFuncDeclId(Context.nCtx, NativeObject); }
/** /**
* The arity of the function declaration * The arity of the function declaration
**/ **/
public Integer Arity() { return Native.getArity(Context.nCtx, NativeObject); } public long Arity() { return Native.getArity(Context.nCtx, NativeObject); }
/** /**
* The size of the domain of the function declaration * The size of the domain of the function declaration
* <seealso cref="Arity"/> * <seealso cref="Arity"/>
**/ **/
public Integer DomainSize() { return Native.getDomainSize(Context.nCtx, NativeObject); } public long DomainSize() { return Native.getDomainSize(Context.nCtx, NativeObject); }
/** /**
* The domain of the function declaration * The domain of the function declaration
@ -75,7 +75,7 @@ package com.Microsoft.Z3;
var n = DomainSize; var n = DomainSize;
Sort[] res = new Sort[n]; Sort[] res = new Sort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Sort.Create(Context, Native.getDomain(Context.nCtx, NativeObject, i)); res[i] = Sort.Create(Context, Native.getDomain(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -83,26 +83,30 @@ package com.Microsoft.Z3;
/** /**
* The range of the function declaration * The range of the function declaration
**/ **/
public Sort Range() { public Sort Range()
{
return Sort.Create(Context, Native.getRange(Context.nCtx, NativeObject)); } return Sort.Create(Context, Native.getRange(Context.nCtx, NativeObject));
}
/** /**
* The kind of the function declaration. * The kind of the function declaration.
**/ **/
public Z3_decl_kind DeclKind() { return (Z3DeclKind)Native.getDeclKind(Context.nCtx, NativeObject); } public Z3_decl_kind DeclKind() { return (Z3_decl_kind)Native.getDeclKind(Context.nCtx, NativeObject); }
/** /**
* The name of the function declaration * The name of the function declaration
**/ **/
public Symbol Name() { public Symbol Name()
{
return Symbol.Create(Context, Native.getDeclName(Context.nCtx, NativeObject)); } return Symbol.Create(Context, Native.getDeclName(Context.nCtx, NativeObject));
}
/** /**
* The number of parameters of the function declaration * The number of parameters of the function declaration
**/ **/
public Integer NumParameters() { return Native.getDeclNumParameters(Context.nCtx, NativeObject); } public long NumParameters() { return Native.getDeclNumParameters(Context.nCtx, NativeObject); }
/** /**
* The parameters of the function declaration * The parameters of the function declaration
@ -111,32 +115,32 @@ package com.Microsoft.Z3;
{ {
Integer num = NumParameters; long num = NumParameters;
Parameter[] res = new Parameter[num]; Parameter[] res = new Parameter[num];
for (Integer i = 0; i < num; i++) for (long i = 0; i < num; i++)
{ {
Z3ParameterKind k = (Z3ParameterKind)Native.getDeclParameterKind(Context.nCtx, NativeObject, i); Z3_parameter_kind k = (Z3_parameter_kind)Native.getDeclParameterKind(Context.nCtx, NativeObject, i);
switch (k) switch (k)
{ {
case Z3ParameterKind.Z3PARAMETERINT: case Z3_parameter_kind.Z3_PARAMETER_INT:
res[i] = new Parameter(k, Native.getDeclIntParameter(Context.nCtx, NativeObject, i)); res[i] = new Parameter(k, Native.getDeclIntParameter(Context.nCtx, NativeObject, i));
break; break;
case Z3ParameterKind.Z3PARAMETERDOUBLE: case Z3_parameter_kind.Z3_PARAMETER_DOUBLE:
res[i] = new Parameter(k, Native.getDeclDoubleParameter(Context.nCtx, NativeObject, i)); res[i] = new Parameter(k, Native.getDeclDoubleParameter(Context.nCtx, NativeObject, i));
break; break;
case Z3ParameterKind.Z3PARAMETERSYMBOL: case Z3_parameter_kind.Z3_PARAMETER_SYMBOL:
res[i] = new Parameter(k, Symbol.Create(Context, Native.getDeclSymbolParameter(Context.nCtx, NativeObject, i))); res[i] = new Parameter(k, Symbol.Create(Context, Native.getDeclSymbolParameter(Context.nCtx, NativeObject, i)));
break; break;
case Z3ParameterKind.Z3PARAMETERSORT: case Z3_parameter_kind.Z3_PARAMETER_SORT:
res[i] = new Parameter(k, Sort.Create(Context, Native.getDeclSortParameter(Context.nCtx, NativeObject, i))); res[i] = new Parameter(k, Sort.Create(Context, Native.getDeclSortParameter(Context.nCtx, NativeObject, i)));
break; break;
case Z3ParameterKind.Z3PARAMETERAST: case Z3_parameter_kind.Z3_PARAMETER_AST:
res[i] = new Parameter(k, new AST(Context, Native.getDeclAstParameter(Context.nCtx, NativeObject, i))); res[i] = new Parameter(k, new AST(Context, Native.getDeclAstParameter(Context.nCtx, NativeObject, i)));
break; break;
case Z3ParameterKind.Z3PARAMETERFUNCDECL: case Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL:
res[i] = new Parameter(k, new FuncDecl(Context, Native.getDeclFuncDeclParameter(Context.nCtx, NativeObject, i))); res[i] = new Parameter(k, new FuncDecl(Context, Native.getDeclFuncDeclParameter(Context.nCtx, NativeObject, i)));
break; break;
case Z3ParameterKind.Z3PARAMETERRATIONAL: case Z3_parameter_kind.Z3_PARAMETER_RATIONAL:
res[i] = new Parameter(k, Native.getDeclRationalParameter(Context.nCtx, NativeObject, i)); res[i] = new Parameter(k, Native.getDeclRationalParameter(Context.nCtx, NativeObject, i));
break; break;
default: default:
@ -151,7 +155,7 @@ package com.Microsoft.Z3;
**/ **/
public class Parameter public class Parameter
{ {
private Z3ParameterKind kind; private Z3_parameter_kind kind;
private int i; private int i;
private double d; private double d;
private Symbol sym; private Symbol sym;
@ -162,46 +166,75 @@ package com.Microsoft.Z3;
/**The int value of the parameter.</summary> /**The int value of the parameter.</summary>
**/ **/
/* Overloaded operators are not translated. */ public int Int () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_INT) throw new Z3Exception("parameter is not an int"); return i; }
/**The double value of the parameter.</summary>
**/
public double Double () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_DOUBLE) throw new Z3Exception("parameter is not a double "); return d; }
/**The Symbol value of the parameter.</summary>
**/
public Symbol Symbol () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_SYMBOL) throw new Z3Exception("parameter is not a Symbol"); return sym; }
/**The Sort value of the parameter.</summary>
**/
public Sort Sort () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_SORT) throw new Z3Exception("parameter is not a Sort"); return srt; }
/**The AST value of the parameter.</summary>
**/
public AST AST () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_AST) throw new Z3Exception("parameter is not an AST"); return ast; }
/**The FunctionDeclaration value of the parameter.</summary>
**/
public FuncDecl FuncDecl () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL) throw new Z3Exception("parameter is not a function declaration"); return fd; }
/**The rational string value of the parameter.</summary>
**/
public String Rational () { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_RATIONAL) throw new Z3Exception("parameter is not a rational String"); return r; }
Parameter(Z3ParameterKind k, double d) /**
* The kind of the parameter.
**/
public Z3_parameter_kind ParameterKind() { return kind; }
Parameter(Z3_parameter_kind k, int i)
{
this.kind = k;
this.i = i;
}
Parameter(Z3_parameter_kind k, double d)
{ {
this.kind = k; this.kind = k;
this.d = d; this.d = d;
} }
Parameter(Z3ParameterKind k, Symbol s) Parameter(Z3_parameter_kind k, Symbol s)
{ {
this.kind = k; this.kind = k;
this.sym = s; this.sym = s;
} }
Parameter(Z3ParameterKind k, Sort s) Parameter(Z3_parameter_kind k, Sort s)
{ {
this.kind = k; this.kind = k;
this.srt = s; this.srt = s;
} }
Parameter(Z3ParameterKind k, AST a) Parameter(Z3_parameter_kind k, AST a)
{ {
this.kind = k; this.kind = k;
this.ast = a; this.ast = a;
} }
Parameter(Z3ParameterKind k, FuncDecl fd) Parameter(Z3_parameter_kind k, FuncDecl fd)
{ {
this.kind = k; this.kind = k;
this.fd = fd; this.fd = fd;
} }
Parameter(Z3ParameterKind k, String r) Parameter(Z3_parameter_kind k, String r)
{ {
this.kind = k; this.kind = k;
this.r = r; this.r = r;
} }
} }
FuncDecl(Context ctx, IntPtr obj) { super(ctx, obj); FuncDecl(Context ctx, IntPtr obj)
{ super(ctx, obj);
} }
@ -224,7 +257,7 @@ package com.Microsoft.Z3;
void CheckNativeObject(IntPtr obj) void CheckNativeObject(IntPtr obj)
{ {
if (Native.getAstKind(Context.nCtx, obj) != (Integer)Z3AstKind.Z3FUNCDECLAST) if (Native.getAstKind(Context.nCtx, obj) != (long)Z3_ast_kind.Z3_FUNC_DECL_AST)
throw new Z3Exception("Underlying object is not a function declaration"); throw new Z3Exception("Underlying object is not a function declaration");
super.CheckNativeObject(obj); super.CheckNativeObject(obj);
} }
@ -234,8 +267,10 @@ package com.Microsoft.Z3;
* <param name="args"></param> * <param name="args"></param>
* @return * @return
**/ **/
public Expr this[params() lic Expr this[params Expr[] args] public Expr this[params() lic Expr this[params Expr[] args
public Expr this[params() { {
public Expr this[params()
{
return Apply(args); return Apply(args);

View file

@ -24,11 +24,12 @@ package com.Microsoft.Z3;
public Expr Value() { public Expr Value() {
return Expr.Create(Context, Native.funcEntryGetValue(Context.nCtx, NativeObject)); } return Expr.Create(Context, Native.funcEntryGetValue(Context.nCtx, NativeObject)); }
}
/** /**
* The number of arguments of the entry. * The number of arguments of the entry.
**/ **/
public Integer NumArgs() { return Native.funcEntryGetNumArgs(Context.nCtx, NativeObject); } public long NumArgs() { return Native.funcEntryGetNumArgs(Context.nCtx, NativeObject); }
/** /**
* The arguments of the function entry. * The arguments of the function entry.
@ -38,9 +39,9 @@ package com.Microsoft.Z3;
Integer n = NumArgs; long n = NumArgs;
Expr[] res = new Expr[n]; Expr[] res = new Expr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Expr.Create(Context, Native.funcEntryGetArg(Context.nCtx, NativeObject, i)); res[i] = Expr.Create(Context, Native.funcEntryGetArg(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -50,10 +51,10 @@ package com.Microsoft.Z3;
**/ **/
public String toString() public String toString()
{ {
Integer n = NumArgs; long n = NumArgs;
String res = "["; String res = "[";
Expr[] args = Args; Expr[] args = Args;
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res += args[i] + ", "; res += args[i] + ", ";
return res + Value + "]"; return res + Value + "]";
} }
@ -75,13 +76,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.FuncEntryDRQ.IncAndClear(Context, o); Context.FuncEntry_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.FuncEntryDRQ.Add(o); Context.FuncEntry_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
}; };
@ -89,7 +90,7 @@ package com.Microsoft.Z3;
/** /**
* The number of entries in the function interpretation. * The number of entries in the function interpretation.
**/ **/
public Integer NumEntries() { return Native.funcInterpGetNumEntries(Context.nCtx, NativeObject); } public long NumEntries() { return Native.funcInterpGetNumEntries(Context.nCtx, NativeObject); }
/** /**
* The entries in the function interpretation * The entries in the function interpretation
@ -100,9 +101,9 @@ package com.Microsoft.Z3;
Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length, Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length,
j => Contract.Result<Entry[]>()[j] != null)); j => Contract.Result<Entry[]>()[j] != null));
Integer n = NumEntries; long n = NumEntries;
Entry[] res = new Entry[n]; Entry[] res = new Entry[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new Entry(Context, Native.funcInterpGetEntry(Context.nCtx, NativeObject, i)); res[i] = new Entry(Context, Native.funcInterpGetEntry(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -114,11 +115,12 @@ package com.Microsoft.Z3;
return Expr.Create(Context, Native.funcInterpGetElse(Context.nCtx, NativeObject)); } return Expr.Create(Context, Native.funcInterpGetElse(Context.nCtx, NativeObject)); }
}
/** /**
* The arity of the function interpretation * The arity of the function interpretation
**/ **/
public Integer Arity() { return Native.funcInterpGetArity(Context.nCtx, NativeObject); } public long Arity() { return Native.funcInterpGetArity(Context.nCtx, NativeObject); }
/** /**
* A string representation of the function interpretation. * A string representation of the function interpretation.
@ -129,10 +131,10 @@ package com.Microsoft.Z3;
res += "["; res += "[";
for (Entry.Iterator e = Entries.iterator(); e.hasNext(); ) for (Entry.Iterator e = Entries.iterator(); e.hasNext(); )
{ {
Integer n = e.NumArgs; long n = e.NumArgs;
if (n > 1) res += "["; if (n > 1) res += "[";
Expr[] args = e.Args; Expr[] args = e.Args;
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
{ {
if (i != 0) res += ", "; if (i != 0) res += ", ";
res += args[i]; res += args[i];
@ -165,13 +167,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.FuncInterpDRQ.IncAndClear(Context, o); Context.FuncInterp_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.FuncInterpDRQ.Add(o); Context.FuncInterp_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -21,26 +21,26 @@ package com.Microsoft.Z3;
* An over approximation is applied when the objective is to find a proof for a given goal. * An over approximation is applied when the objective is to find a proof for a given goal.
* </remarks> * </remarks>
**/ **/
public Z3_goal_prec Precision() { return (Z3GoalPrec)Native.goalPrecision(Context.nCtx, NativeObject); } public Z3_goal_prec Precision() { return (Z3_goal_prec)Native.goalPrecision(Context.nCtx, NativeObject); }
/** /**
* Indicates whether the goal is precise. * Indicates whether the goal is precise.
**/ **/
public boolean IsPrecise() { return Precision == Z3GoalPrec.Z3GOALPRECISE; } public boolean IsPrecise() { return Precision == Z3_goal_prec.Z3_GOAL_PRECISE; }
/** /**
* Indicates whether the goal is an under-approximation. * Indicates whether the goal is an under-approximation.
**/ **/
public boolean IsUnderApproximation() { return Precision == Z3GoalPrec.Z3GOALUNDER; } public boolean IsUnderApproximation() { return Precision == Z3_goal_prec.Z3_GOAL_UNDER; }
/** /**
* Indicates whether the goal is an over-approximation. * Indicates whether the goal is an over-approximation.
**/ **/
public boolean IsOverApproximation() { return Precision == Z3GoalPrec.Z3GOALOVER; } public boolean IsOverApproximation() { return Precision == Z3_goal_prec.Z3_GOAL_OVER; }
/** /**
* Indicates whether the goal is garbage (i.e., the product of over- and under-approximations). * Indicates whether the goal is garbage (i.e., the product of over- and under-approximations).
**/ **/
public boolean IsGarbage() { return Precision == Z3GoalPrec.Z3GOALUNDEROVER; } public boolean IsGarbage() { return Precision == Z3_goal_prec.Z3_GOAL_UNDER_OVER; }
/** /**
* Adds the <paramref name="constraints"/> to the given goal. * Adds the <paramref name="constraints"/> to the given goal.
@ -69,7 +69,7 @@ package com.Microsoft.Z3;
* This tracks how many transformations were applied to it. * This tracks how many transformations were applied to it.
* </remarks> * </remarks>
**/ **/
public Integer Depth() { return Native.goalDepth(Context.nCtx, NativeObject); } public long Depth() { return Native.goalDepth(Context.nCtx, NativeObject); }
/** /**
* Erases all formulas from the given goal. * Erases all formulas from the given goal.
@ -82,7 +82,7 @@ package com.Microsoft.Z3;
/** /**
* The number of formulas in the goal. * The number of formulas in the goal.
**/ **/
public Integer Size() { return Native.goalSize(Context.nCtx, NativeObject); } public long Size() { return Native.goalSize(Context.nCtx, NativeObject); }
/** /**
* The formulas in the goal. * The formulas in the goal.
@ -91,9 +91,9 @@ package com.Microsoft.Z3;
{ {
Integer n = Size; long n = Size;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new BoolExpr(Context, Native.goalFormula(Context.nCtx, NativeObject, i)); res[i] = new BoolExpr(Context, Native.goalFormula(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -101,7 +101,7 @@ package com.Microsoft.Z3;
/** /**
* The number of formulas, subformulas and terms in the goal. * The number of formulas, subformulas and terms in the goal.
**/ **/
public Integer NumExprs() { return Native.goalNumExprs(Context.nCtx, NativeObject); } public long NumExprs() { return Native.goalNumExprs(Context.nCtx, NativeObject); }
/** /**
* Indicates whether the goal is empty, and it is precise or the product of an under approximation. * Indicates whether the goal is empty, and it is precise or the product of an under approximation.
@ -169,13 +169,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.GoalDRQ.IncAndClear(Context, o); Context.Goal_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.GoalDRQ.Add(o); Context.Goal_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }

View file

@ -15,7 +15,7 @@ package com.Microsoft.Z3;
**/ **/
public final class Log public final class Log
{ {
private boolean mIsOpen = false; private boolean m_is_open = false;
/** /**
* Open an interaction log file. * Open an interaction log file.
@ -24,7 +24,7 @@ package com.Microsoft.Z3;
**/ **/
public boolean Open(String filename) public boolean Open(String filename)
{ {
mIsOpen = true; m_is_open = true;
return Native.openLog(filename) == 1; return Native.openLog(filename) == 1;
} }
@ -33,7 +33,7 @@ package com.Microsoft.Z3;
**/ **/
public void Close() public void Close()
{ {
mIsOpen = false; m_is_open = false;
Native.closeLog(); Native.closeLog();
} }
@ -44,7 +44,7 @@ package com.Microsoft.Z3;
{ {
if (!mIsOpen) if (!m_is_open)
throw new Z3Exception("Log cannot be closed."); throw new Z3Exception("Log cannot be closed.");
Native.appendLog(s); Native.appendLog(s);
} }
@ -55,6 +55,6 @@ package com.Microsoft.Z3;
**/ **/
public boolean isOpen() public boolean isOpen()
{ {
return mIsOpen; return m_is_open;
} }
} }

View file

@ -35,7 +35,7 @@ package com.Microsoft.Z3;
Context.CheckContextMatch(f); Context.CheckContextMatch(f);
if (f.Arity != 0 || if (f.Arity != 0 ||
Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject)) == (Integer)Z3SortKind.Z3ARRAYSORT) Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject)) == (long)Z3_sort_kind.Z3_ARRAY_SORT)
throw new Z3Exception("Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp."); throw new Z3Exception("Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp.");
IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject); IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject);
@ -56,13 +56,13 @@ package com.Microsoft.Z3;
Context.CheckContextMatch(f); Context.CheckContextMatch(f);
Z3SortKind sk = (Z3SortKind)Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject)); Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject));
if (f.Arity == 0) if (f.Arity == 0)
{ {
IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject); IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject);
if (sk == Z3SortKind.Z3ARRAYSORT) if (sk == Z3_sort_kind.Z3_ARRAY_SORT)
{ {
if (n == IntPtr.Zero) if (n == IntPtr.Zero)
return null; return null;
@ -92,7 +92,7 @@ package com.Microsoft.Z3;
/** /**
* The number of constants that have an interpretation in the model. * The number of constants that have an interpretation in the model.
**/ **/
public Integer NumConsts() { return Native.modelGetNumConsts(Context.nCtx, NativeObject); } public long NumConsts() { return Native.modelGetNumConsts(Context.nCtx, NativeObject); }
/** /**
* The function declarations of the constants in the model. * The function declarations of the constants in the model.
@ -101,9 +101,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumConsts; long n = NumConsts;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -111,7 +111,7 @@ package com.Microsoft.Z3;
/** /**
* The number of function interpretations in the model. * The number of function interpretations in the model.
**/ **/
public Integer NumFuncs() { return Native.modelGetNumFuncs(Context.nCtx, NativeObject); } public long NumFuncs() { return Native.modelGetNumFuncs(Context.nCtx, NativeObject); }
/** /**
* The function declarations of the function interpretations in the model. * The function declarations of the function interpretations in the model.
@ -120,9 +120,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumFuncs; long n = NumFuncs;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -136,11 +136,11 @@ package com.Microsoft.Z3;
var nFuncs = NumFuncs; var nFuncs = NumFuncs;
var nConsts = NumConsts; var nConsts = NumConsts;
Integer n = nFuncs + nConsts; long n = nFuncs + nConsts;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < nConsts; i++) for (long i = 0; i < nConsts; i++)
res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i));
for (Integer i = 0; i < nFuncs; i++) for (long i = 0; i < nFuncs; i++)
res[nConsts + i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i)); res[nConsts + i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -196,7 +196,7 @@ package com.Microsoft.Z3;
/** /**
* The number of uninterpreted sorts that the model has an interpretation for. * The number of uninterpreted sorts that the model has an interpretation for.
**/ **/
public Integer NumSorts () { return Native.modelGetNumSorts(Context.nCtx, NativeObject); } public long NumSorts () { return Native.modelGetNumSorts(Context.nCtx, NativeObject); }
/** /**
* The uninterpreted sorts that the model has an interpretation for. * The uninterpreted sorts that the model has an interpretation for.
@ -212,9 +212,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumSorts; long n = NumSorts;
Sort[] res = new Sort[n]; Sort[] res = new Sort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Sort.Create(Context, Native.modelGetSort(Context.nCtx, NativeObject, i)); res[i] = Sort.Create(Context, Native.modelGetSort(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -231,9 +231,9 @@ package com.Microsoft.Z3;
ASTVector nUniv = new ASTVector(Context, Native.modelGetSortUniverse(Context.nCtx, NativeObject, s.NativeObject)); ASTVector nUniv = new ASTVector(Context, Native.modelGetSortUniverse(Context.nCtx, NativeObject, s.NativeObject));
Integer n = nUniv.Size; long n = nUniv.Size;
Expr[] res = new Expr[n]; Expr[] res = new Expr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Expr.Create(Context, nUniv[i].NativeObject); res[i] = Expr.Create(Context, nUniv[i].NativeObject);
return res; return res;
} }
@ -267,13 +267,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ModelDRQ.IncAndClear(Context, o); Context.Model_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ModelDRQ.Add(o); Context.Model_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -1,7 +1,10 @@
// Automatically generated file // Automatically generated file
package com.Microsoft.Z3; package com.Microsoft.Z3;
public final class Native { public final class Native {
static { System.loadLibrary("<mk_util.JavaDLLComponent instance at 0x0240DCD8>"); } public static class IntPtr { public int value; }
public static class LongPtr { public long value; }
public static class StringPtr { public String value; }
static { System.loadLibrary("<mk_util.JavaDLLComponent instance at 0x0251B738>"); }
public static native long mkConfig(); public static native long mkConfig();
public static native void delConfig(long a0); public static native void delConfig(long a0);
public static native void setParamValue(long a0, String a1, String a2); public static native void setParamValue(long a0, String a1, String a2);
@ -487,8 +490,8 @@ public final class Native {
public static native String statisticsToString(long a0); public static native String statisticsToString(long a0);
public static native long getContextAssignment(long a0); public static native long getContextAssignment(long a0);
public static void main(String[] args) { public static void main(String[] args) {
Integer major = 0, minor = 0, build = 0, revision = 0; IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr();
getVersion(major, minor, build, revision); getVersion(major, minor, build, revision);
System.out.format("Z3 (for Java) %d.%d.%d%n", major, minor, build); System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value);
} }
} }

View file

@ -25,7 +25,7 @@ package com.Microsoft.Z3;
public UInt64 UInt64() public UInt64 UInt64()
{ {
UInt64 res = 0; UInt64 res = 0;
if (Native.getNumeralInteger64(Context.nCtx, NativeObject, res) == 0) if (Native.getNumeralLong64(Context.nCtx, NativeObject, res) == 0)
throw new Z3Exception("Numeral is not a 64 bit unsigned"); throw new Z3Exception("Numeral is not a 64 bit unsigned");
return res; return res;
} }
@ -55,11 +55,11 @@ package com.Microsoft.Z3;
/** /**
* Retrieve the int value. * Retrieve the int value.
**/ **/
public Integer UInt() public long UInt()
{ {
Integer res = 0; long res = 0;
if (Native.getNumeralInteger(Context.nCtx, NativeObject, res) == 0) if (Native.getNumeralLong(Context.nCtx, NativeObject, res) == 0)
throw new Z3Exception("Numeral is not a Integer"); throw new Z3Exception("Numeral is not a long");
return res; return res;
} }
@ -92,6 +92,7 @@ package com.Microsoft.Z3;
return new IntNum(Context, Native.getNumerator(Context.nCtx, NativeObject)); } return new IntNum(Context, Native.getNumerator(Context.nCtx, NativeObject)); }
}
/** /**
* The denominator of a rational numeral. * The denominator of a rational numeral.
@ -100,6 +101,7 @@ package com.Microsoft.Z3;
return new IntNum(Context, Native.getDenominator(Context.nCtx, NativeObject)); } return new IntNum(Context, Native.getDenominator(Context.nCtx, NativeObject)); }
}
/** /**
* Converts the numerator of the rational to a BigInteger * Converts the numerator of the rational to a BigInteger
@ -123,7 +125,7 @@ package com.Microsoft.Z3;
* Returns a string representation in decimal notation. * Returns a string representation in decimal notation.
* <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks> * <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
**/ **/
public String ToDecimalString(Integer precision) public String ToDecimalString(long precision)
{ {
return Native.getNumeralDecimalString(Context.nCtx, NativeObject, precision); return Native.getNumeralDecimalString(Context.nCtx, NativeObject, precision);
} }
@ -154,7 +156,7 @@ package com.Microsoft.Z3;
public UInt64 UInt64() public UInt64 UInt64()
{ {
UInt64 res = 0; UInt64 res = 0;
if (Native.getNumeralInteger64(Context.nCtx, NativeObject, res) == 0) if (Native.getNumeralLong64(Context.nCtx, NativeObject, res) == 0)
throw new Z3Exception("Numeral is not a 64 bit unsigned"); throw new Z3Exception("Numeral is not a 64 bit unsigned");
return res; return res;
} }
@ -184,11 +186,11 @@ package com.Microsoft.Z3;
/** /**
* Retrieve the int value. * Retrieve the int value.
**/ **/
public Integer UInt() public long UInt()
{ {
Integer res = 0; long res = 0;
if (Native.getNumeralInteger(Context.nCtx, NativeObject, res) == 0) if (Native.getNumeralLong(Context.nCtx, NativeObject, res) == 0)
throw new Z3Exception("Numeral is not a Integer"); throw new Z3Exception("Numeral is not a long");
return res; return res;
} }
@ -223,7 +225,7 @@ package com.Microsoft.Z3;
* <param name="precision">the precision of the result</param> * <param name="precision">the precision of the result</param>
* @return A numeral Expr of sort Real * @return A numeral Expr of sort Real
**/ **/
public RatNum ToUpper(Integer precision) public RatNum ToUpper(long precision)
{ {
@ -237,7 +239,7 @@ package com.Microsoft.Z3;
* <param name="precision"></param> * <param name="precision"></param>
* @return A numeral Expr of sort Real * @return A numeral Expr of sort Real
**/ **/
public RatNum ToLower(Integer precision) public RatNum ToLower(long precision)
{ {
@ -248,7 +250,7 @@ package com.Microsoft.Z3;
* Returns a string representation in decimal notation. * Returns a string representation in decimal notation.
* <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks> * <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
**/ **/
public String ToDecimal(Integer precision) public String ToDecimal(long precision)
{ {

View file

@ -23,10 +23,10 @@ package com.Microsoft.Z3;
/** /**
* Retrieve kind of parameter. * Retrieve kind of parameter.
**/ **/
public Z3ParamKind GetKind(Symbol name) public Z3_param_kind GetKind(Symbol name)
{ {
return (Z3ParamKind)Native.paramDescrsGetKind(Context.nCtx, NativeObject, name.NativeObject); return (Z3_param_kind)Native.paramDescrsGetKind(Context.nCtx, NativeObject, name.NativeObject);
} }
/** /**
@ -34,18 +34,18 @@ package com.Microsoft.Z3;
**/ **/
public Symbol[] Names() public Symbol[] Names()
{ {
Integer sz = Native.paramDescrsSize(Context.nCtx, NativeObject); long sz = Native.paramDescrsSize(Context.nCtx, NativeObject);
Symbol[] names = new Symbol[sz]; Symbol[] names = new Symbol[sz];
for (Integer i = 0; i < sz; ++i) { for (long i = 0; i < sz; ++i) {
names[i] = Symbol.Create(Context, Native.paramDescrsGetName(Context.nCtx, NativeObject, i)); names[i] = Symbol.Create(Context, Native.paramDescrsGetName(Context.nCtx, NativeObject, i));
return names;
} }
return names;
} }
/** /**
* The size of the ParamDescrs. * The size of the ParamDescrs.
**/ **/
public Integer Size() { return Native.paramDescrsSize(Context.nCtx, NativeObject); } public long Size() { return Native.paramDescrsSize(Context.nCtx, NativeObject); }
/** /**
* Retrieves a string representation of the ParamDescrs. * Retrieves a string representation of the ParamDescrs.
@ -75,13 +75,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ParamDescrsDRQ.IncAndClear(Context, o); Context.ParamDescrs_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ParamDescrsDRQ.Add(o); Context.ParamDescrs_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -24,11 +24,11 @@ package com.Microsoft.Z3;
/** /**
* Adds a parameter setting. * Adds a parameter setting.
**/ **/
public void Add(Symbol name, Integer value) public void Add(Symbol name, long value)
{ {
Native.paramsSetInteger(Context.nCtx, NativeObject, name.NativeObject, value); Native.paramsSetLong(Context.nCtx, NativeObject, name.NativeObject, value);
} }
/** /**
@ -63,9 +63,9 @@ package com.Microsoft.Z3;
/** /**
* Adds a parameter setting. * Adds a parameter setting.
**/ **/
public void Add(String name, Integer value) public void Add(String name, long value)
{ {
Native.paramsSetInteger(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value); Native.paramsSetLong(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value);
} }
/** /**
@ -114,13 +114,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ParamsDRQ.IncAndClear(Context, o); Context.Params_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ParamsDRQ.Add(o); Context.Params_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -17,7 +17,7 @@ package com.Microsoft.Z3;
/** /**
* The number of terms in the pattern. * The number of terms in the pattern.
**/ **/
public Integer NumTerms() { return Native.getPatternNumTerms(Context.nCtx, NativeObject); } public long NumTerms() { return Native.getPatternNumTerms(Context.nCtx, NativeObject); }
/** /**
* The terms in the pattern. * The terms in the pattern.
@ -26,9 +26,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumTerms; long n = NumTerms;
Expr[] res = new Expr[n]; Expr[] res = new Expr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Expr.Create(Context, Native.getPattern(Context.nCtx, NativeObject, i)); res[i] = Expr.Create(Context, Native.getPattern(Context.nCtx, NativeObject, i));
return res; return res;
} }

View file

@ -60,13 +60,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.ProbeDRQ.IncAndClear(Context, o); Context.Probe_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.ProbeDRQ.Add(o); Context.Probe_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -24,12 +24,12 @@ package com.Microsoft.Z3;
/** /**
* The weight of the quantifier. * The weight of the quantifier.
**/ **/
public Integer Weight() { return Native.getQuantifierWeight(Context.nCtx, NativeObject); } public long Weight() { return Native.getQuantifierWeight(Context.nCtx, NativeObject); }
/** /**
* The number of patterns. * The number of patterns.
**/ **/
public Integer NumPatterns() { return Native.getQuantifierNumPatterns(Context.nCtx, NativeObject); } public long NumPatterns() { return Native.getQuantifierNumPatterns(Context.nCtx, NativeObject); }
/** /**
* The patterns. * The patterns.
@ -38,9 +38,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumPatterns; long n = NumPatterns;
Pattern[] res = new Pattern[n]; Pattern[] res = new Pattern[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new Pattern(Context, Native.getQuantifierPatternAst(Context.nCtx, NativeObject, i)); res[i] = new Pattern(Context, Native.getQuantifierPatternAst(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -48,7 +48,7 @@ package com.Microsoft.Z3;
/** /**
* The number of no-patterns. * The number of no-patterns.
**/ **/
public Integer NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context.nCtx, NativeObject); } public long NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context.nCtx, NativeObject); }
/** /**
* The no-patterns. * The no-patterns.
@ -57,9 +57,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumNoPatterns; long n = NumNoPatterns;
Pattern[] res = new Pattern[n]; Pattern[] res = new Pattern[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new Pattern(Context, Native.getQuantifierNoPatternAst(Context.nCtx, NativeObject, i)); res[i] = new Pattern(Context, Native.getQuantifierNoPatternAst(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -67,7 +67,7 @@ package com.Microsoft.Z3;
/** /**
* The number of bound variables. * The number of bound variables.
**/ **/
public Integer NumBound() { return Native.getQuantifierNumBound(Context.nCtx, NativeObject); } public long NumBound() { return Native.getQuantifierNumBound(Context.nCtx, NativeObject); }
/** /**
* The symbols for the bound variables. * The symbols for the bound variables.
@ -76,9 +76,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumBound; long n = NumBound;
Symbol[] res = new Symbol[n]; Symbol[] res = new Symbol[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Symbol.Create(Context, Native.getQuantifierBoundName(Context.nCtx, NativeObject, i)); res[i] = Symbol.Create(Context, Native.getQuantifierBoundName(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -90,9 +90,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumBound; long n = NumBound;
Sort[] res = new Sort[n]; Sort[] res = new Sort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Sort.Create(Context, Native.getQuantifierBoundSort(Context.nCtx, NativeObject, i)); res[i] = Sort.Create(Context, Native.getQuantifierBoundSort(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -104,9 +104,10 @@ package com.Microsoft.Z3;
return new BoolExpr(Context, Native.getQuantifierBody(Context.nCtx, NativeObject)); } return new BoolExpr(Context, Native.getQuantifierBody(Context.nCtx, NativeObject)); }
}
Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body, Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body,
Integer weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, long weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null,
Symbol quantifierID = null, Symbol skolemID = null Symbol quantifierID = null, Symbol skolemID = null
) )
{ super(ctx); { super(ctx);
@ -129,7 +130,7 @@ package com.Microsoft.Z3;
if (sorts.Length != names.Length) if (sorts.Length != names.Length)
throw new Z3Exception("Number of sorts does not match number of names"); throw new Z3Exception("Number of sorts does not match number of names");
IntPtr[] Patterns = AST.ArrayToNative(patterns); IntPtr[] _patterns = AST.ArrayToNative(patterns);
if (noPatterns == null && quantifierID == null && skolemID == null) if (noPatterns == null && quantifierID == null && skolemID == null)
{ {
@ -138,7 +139,6 @@ package com.Microsoft.Z3;
AST.ArrayLength(sorts), AST.ArrayToNative(sorts), AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
Symbol.ArrayToNative(names), Symbol.ArrayToNative(names),
body.NativeObject); body.NativeObject);
}
else else
{ {
NativeObject = Native.mkQuantifierEx(ctx.nCtx, (isForall) ? 1 : 0, weight, NativeObject = Native.mkQuantifierEx(ctx.nCtx, (isForall) ? 1 : 0, weight,
@ -152,7 +152,7 @@ package com.Microsoft.Z3;
} }
Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body, Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body,
Integer weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, long weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null,
Symbol quantifierID = null, Symbol skolemID = null Symbol quantifierID = null, Symbol skolemID = null
) )
{ super(ctx); { super(ctx);
@ -191,7 +191,7 @@ package com.Microsoft.Z3;
void CheckNativeObject(IntPtr obj) void CheckNativeObject(IntPtr obj)
{ {
if ((Z3AstKind)Native.getAstKind(Context.nCtx, obj) != Z3AstKind.Z3QUANTIFIERAST) if ((Z3_ast_kind)Native.getAstKind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST)
throw new Z3Exception("Underlying object is not a quantifier"); throw new Z3Exception("Underlying object is not a quantifier");
super.CheckNativeObject(obj); super.CheckNativeObject(obj);
} }

View file

@ -43,7 +43,7 @@ package com.Microsoft.Z3;
* <seealso cref="Pop"/> * <seealso cref="Pop"/>
* <seealso cref="Push"/> * <seealso cref="Push"/>
**/ **/
public Integer NumScopes() { return Native.solverGetNumScopes(Context.nCtx, NativeObject); } public long NumScopes() { return Native.solverGetNumScopes(Context.nCtx, NativeObject); }
/** /**
* Creates a backtracking point. * Creates a backtracking point.
@ -59,7 +59,7 @@ package com.Microsoft.Z3;
* <remarks>Note that an exception is thrown if <paramref name="n"/> is not smaller than <code>NumScopes</code></remarks> * <remarks>Note that an exception is thrown if <paramref name="n"/> is not smaller than <code>NumScopes</code></remarks>
* <seealso cref="Push"/> * <seealso cref="Push"/>
**/ **/
public void Pop(Integer n) public void Pop(long n)
{ {
Native.solverPop(Context.nCtx, NativeObject, n); Native.solverPop(Context.nCtx, NativeObject, n);
} }
@ -91,7 +91,7 @@ package com.Microsoft.Z3;
/** /**
* The number of assertions in the solver. * The number of assertions in the solver.
**/ **/
public Integer NumAssertions() public long NumAssertions()
{ {
ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject)); ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject));
return ass.Size; return ass.Size;
@ -105,9 +105,9 @@ package com.Microsoft.Z3;
ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject)); ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject));
Integer n = ass.Size; long n = ass.Size;
BoolExpr[] res = new BoolExpr[n]; BoolExpr[] res = new BoolExpr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new BoolExpr(Context, ass[i].NativeObject); res[i] = new BoolExpr(Context, ass[i].NativeObject);
return res; return res;
} }
@ -122,15 +122,15 @@ package com.Microsoft.Z3;
**/ **/
public Status Check(Expr[] assumptions) public Status Check(Expr[] assumptions)
{ {
Z3Lboolean r; Z3_lboolean r;
if (assumptions == null) if (assumptions == null)
r = (Z3Lboolean)Native.solverCheck(Context.nCtx, NativeObject); r = (Z3_lboolean)Native.solverCheck(Context.nCtx, NativeObject);
else else
r = (Z3Lboolean)Native.solverCheckAssumptions(Context.nCtx, NativeObject, (Integer)assumptions.Length, AST.ArrayToNative(assumptions)); r = (Z3_lboolean)Native.solverCheckAssumptions(Context.nCtx, NativeObject, (long)assumptions.Length, AST.ArrayToNative(assumptions));
switch (r) switch (r)
{ {
case Z3Lboolean.Z3LTRUE: return Status.SATISFIABLE; case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE;
case Z3Lboolean.Z3LFALSE: return Status.UNSATISFIABLE; case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE;
default: return Status.UNKNOWN; default: return Status.UNKNOWN;
} }
} }
@ -180,9 +180,9 @@ package com.Microsoft.Z3;
ASTVector core = new ASTVector(Context, Native.solverGetUnsatCore(Context.nCtx, NativeObject)); ASTVector core = new ASTVector(Context, Native.solverGetUnsatCore(Context.nCtx, NativeObject));
Integer n = core.Size; long n = core.Size;
Expr[] res = new Expr[n]; Expr[] res = new Expr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Expr.Create(Context, core[i].NativeObject); res[i] = Expr.Create(Context, core[i].NativeObject);
return res; return res;
} }
@ -235,13 +235,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.SolverDRQ.IncAndClear(Context, o); Context.Solver_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.SolverDRQ.Add(o); Context.Solver_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -53,12 +53,12 @@ package com.Microsoft.Z3;
/** /**
* Returns a unique identifier for the sort. * Returns a unique identifier for the sort.
**/ **/
new public Integer Id() { return Native.getSortId(Context.nCtx, NativeObject); } public long Id() { return Native.getSortId(Context.nCtx, NativeObject); }
/** /**
* The kind of the sort. * The kind of the sort.
**/ **/
public Z3_sort_kind SortKind() { return (Z3SortKind)Native.getSortKind(Context.nCtx, NativeObject); } public Z3_sort_kind SortKind() { return (Z3_sort_kind)Native.getSortKind(Context.nCtx, NativeObject); }
/** /**
* The name of the sort * The name of the sort
@ -66,6 +66,7 @@ package com.Microsoft.Z3;
public Symbol Name() { public Symbol Name() {
return Symbol.Create(Context, Native.getSortName(Context.nCtx, NativeObject)); } return Symbol.Create(Context, Native.getSortName(Context.nCtx, NativeObject)); }
}
/** /**
* A string representation of the sort. * A string representation of the sort.
@ -73,7 +74,6 @@ package com.Microsoft.Z3;
public String toString() public String toString()
{ {
return Native.sorttoString(Context.nCtx, NativeObject); return Native.sorttoString(Context.nCtx, NativeObject);
}
/** /**
* Sort constructor * Sort constructor
@ -83,27 +83,27 @@ package com.Microsoft.Z3;
void CheckNativeObject(IntPtr obj) void CheckNativeObject(IntPtr obj)
{ {
if (Native.getAstKind(Context.nCtx, obj) != (Integer)Z3AstKind.Z3SORTAST) if (Native.getAstKind(Context.nCtx, obj) != (long)Z3_ast_kind.Z3_SORT_AST)
throw new Z3Exception("Underlying object is not a sort"); throw new Z3Exception("Underlying object is not a sort");
super.CheckNativeObject(obj); super.CheckNativeObject(obj);
} }
new static Sort Create(Context ctx, IntPtr obj) static Sort Create(Context ctx, IntPtr obj)
{ {
switch ((Z3SortKind)Native.getSortKind(ctx.nCtx, obj)) switch ((Z3_sort_kind)Native.getSortKind(ctx.nCtx, obj))
{ {
case Z3SortKind.Z3ARRAYSORT: return new ArraySort(ctx, obj); case Z3_sort_kind.Z3_ARRAY_SORT: return new ArraySort(ctx, obj);
case Z3SortKind.Z3BOOLSORT: return new BoolSort(ctx, obj); case Z3_sort_kind.Z3_BOOL_SORT: return new BoolSort(ctx, obj);
case Z3SortKind.Z3BVSORT: return new BitVecSort(ctx, obj); case Z3_sort_kind.Z3_BV_SORT: return new BitVecSort(ctx, obj);
case Z3SortKind.Z3DATATYPESORT: return new DatatypeSort(ctx, obj); case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeSort(ctx, obj);
case Z3SortKind.Z3INTSORT: return new IntSort(ctx, obj); case Z3_sort_kind.Z3_INT_SORT: return new IntSort(ctx, obj);
case Z3SortKind.Z3REALSORT: return new RealSort(ctx, obj); case Z3_sort_kind.Z3_REAL_SORT: return new RealSort(ctx, obj);
case Z3SortKind.Z3UNINTERPRETEDSORT: return new UninterpretedSort(ctx, obj); case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj);
case Z3SortKind.Z3FINITEDOMAINSORT: return new FiniteDomainSort(ctx, obj); case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj);
case Z3SortKind.Z3RELATIONSORT: return new RelationSort(ctx, obj); case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj);
default: default:
throw new Z3Exception("Unknown sort kind"); throw new Z3Exception("Unknown sort kind");
} }
@ -165,10 +165,10 @@ package com.Microsoft.Z3;
/** /**
* The size of the bit-vector sort. * The size of the bit-vector sort.
**/ **/
public Integer Size() { return Native.getBvSortSize(Context.nCtx, NativeObject); } public long Size() { return Native.getBvSortSize(Context.nCtx, NativeObject); }
BitVecSort(Context ctx, IntPtr obj) { super(ctx, obj); } BitVecSort(Context ctx, IntPtr obj) { super(ctx, obj); }
BitVecSort(Context ctx, Integer size) { super(ctx, Native.mkBvSort(ctx.nCtx, size)); } BitVecSort(Context ctx, long size) { super(ctx, Native.mkBvSort(ctx.nCtx, size)); }
}; };
/** /**
@ -183,6 +183,7 @@ package com.Microsoft.Z3;
return Sort.Create(Context, Native.getArraySortDomain(Context.nCtx, NativeObject)); } return Sort.Create(Context, Native.getArraySortDomain(Context.nCtx, NativeObject)); }
}
/** /**
* The range of the array sort. * The range of the array sort.
@ -191,6 +192,7 @@ package com.Microsoft.Z3;
return Sort.Create(Context, Native.getArraySortRange(Context.nCtx, NativeObject)); } return Sort.Create(Context, Native.getArraySortRange(Context.nCtx, NativeObject)); }
}
ArraySort(Context ctx, IntPtr obj) { super(ctx, obj); } ArraySort(Context ctx, IntPtr obj) { super(ctx, obj); }
ArraySort(Context ctx, Sort domain, Sort range) ArraySort(Context ctx, Sort domain, Sort range)
@ -198,7 +200,6 @@ package com.Microsoft.Z3;
}
}; };
/** /**
@ -209,7 +210,7 @@ package com.Microsoft.Z3;
/** /**
* The number of constructors of the datatype sort. * The number of constructors of the datatype sort.
**/ **/
public Integer NumConstructors() { return Native.getDatatypeSortNumConstructors(Context.nCtx, NativeObject); } public long NumConstructors() { return Native.getDatatypeSortNumConstructors(Context.nCtx, NativeObject); }
/** /**
* The constructors. * The constructors.
@ -218,9 +219,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumConstructors; long n = NumConstructors;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -232,9 +233,9 @@ package com.Microsoft.Z3;
{ {
Integer n = NumConstructors; long n = NumConstructors;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(Context, Native.getDatatypeSortRecognizer(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.getDatatypeSortRecognizer(Context.nCtx, NativeObject, i));
return res; return res;
} }
@ -246,24 +247,24 @@ package com.Microsoft.Z3;
{ {
Integer n = NumConstructors; long n = NumConstructors;
FuncDecl[][] res = new FuncDecl[n][]; FuncDecl[][] res = new FuncDecl[n][];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
{ {
FuncDecl fd = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i)); FuncDecl fd = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i));
Integer ds = fd.DomainSize; long ds = fd.DomainSize;
FuncDecl[] tmp = new FuncDecl[ds]; FuncDecl[] tmp = new FuncDecl[ds];
for (Integer j = 0; j < ds; j++) for (long j = 0; j < ds; j++)
tmp[j] = new FuncDecl(Context, Native.getDatatypeSortConstructorAccessor(Context.nCtx, NativeObject, i, j)); tmp[j] = new FuncDecl(Context, Native.getDatatypeSortConstructorAccessor(Context.nCtx, NativeObject, i, j));
res[i] = tmp; res[i] = tmp;
return res;
} }
return res;
} }
DatatypeSort(Context ctx, IntPtr obj) { super(ctx, obj); } DatatypeSort(Context ctx, IntPtr obj) { super(ctx, obj); }
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
{ super(ctx, Native.mkDatatype(ctx.nCtx, name.NativeObject, (Integer)constructors.Length, ArrayToNative(constructors))); { super(ctx, Native.mkDatatype(ctx.nCtx, name.NativeObject, (long)constructors.Length, ArrayToNative(constructors)));
@ -298,11 +299,12 @@ package com.Microsoft.Z3;
return new FuncDecl(Context, Native.getTupleSortMkDecl(Context.nCtx, NativeObject)); } return new FuncDecl(Context, Native.getTupleSortMkDecl(Context.nCtx, NativeObject)); }
}
/** /**
* The number of fields in the tuple. * The number of fields in the tuple.
**/ **/
public Integer NumFields() { return Native.getTupleSortNumFields(Context.nCtx, NativeObject); } public long NumFields() { return Native.getTupleSortNumFields(Context.nCtx, NativeObject); }
/** /**
* The field declarations. * The field declarations.
@ -311,14 +313,14 @@ package com.Microsoft.Z3;
{ {
Integer n = NumFields; long n = NumFields;
FuncDecl[] res = new FuncDecl[n]; FuncDecl[] res = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = new FuncDecl(Context, Native.getTupleSortFieldDecl(Context.nCtx, NativeObject, i)); res[i] = new FuncDecl(Context, Native.getTupleSortFieldDecl(Context.nCtx, NativeObject, i));
return res; return res;
} }
TupleSort(Context ctx, Symbol name, Integer numFields, Symbol[] fieldNames, Sort[] fieldSorts) TupleSort(Context ctx, Symbol name, long numFields, Symbol[] fieldNames, Sort[] fieldSorts)
{ super(ctx); { super(ctx);
@ -341,7 +343,8 @@ package com.Microsoft.Z3;
public FuncDecl[] ConstDecls() { public FuncDecl[] ConstDecls() {
return Constdecls; } return _constdecls; }
}
/** /**
* The constants in the enumeration. * The constants in the enumeration.
@ -349,7 +352,8 @@ package com.Microsoft.Z3;
public Expr[] Consts() { public Expr[] Consts() {
return Consts; } return _consts; }
}
/** /**
* The test predicates for the constants in the enumeration. * The test predicates for the constants in the enumeration.
@ -357,7 +361,7 @@ package com.Microsoft.Z3;
public FuncDecl[] TesterDecls() { public FuncDecl[] TesterDecls() {
return Testerdecls; return _testerdecls;
} }
@ -370,8 +374,8 @@ package com.Microsoft.Z3;
private FuncDecl[] Constdecls = null, Testerdecls = null; private FuncDecl[] _constdecls = null, _testerdecls = null;
private Expr[] Consts = null; private Expr[] _consts = null;
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
{ super(ctx); { super(ctx);
@ -380,19 +384,19 @@ package com.Microsoft.Z3;
int n = enumNames.Length; int n = enumNames.Length;
IntPtr[] nConstdecls = new IntPtr[n]; IntPtr[] n_constdecls = new IntPtr[n];
IntPtr[] nTesters = new IntPtr[n]; IntPtr[] n_testers = new IntPtr[n];
NativeObject = Native.mkEnumerationSort(ctx.nCtx, name.NativeObject, (Integer)n, NativeObject = Native.mkEnumerationSort(ctx.nCtx, name.NativeObject, (long)n,
Symbol.ArrayToNative(enumNames), nConstdecls, nTesters); Symbol.ArrayToNative(enumNames), n_constdecls, n_testers);
Constdecls = new FuncDecl[n]; _constdecls = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
Constdecls[i] = new FuncDecl(ctx, nConstdecls[i]); _constdecls[i] = new FuncDecl(ctx, n_constdecls[i]);
Testerdecls = new FuncDecl[n]; _testerdecls = new FuncDecl[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
Testerdecls[i] = new FuncDecl(ctx, nTesters[i]); _testerdecls[i] = new FuncDecl(ctx, n_testers[i]);
Consts = new Expr[n]; _consts = new Expr[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
Consts[i] = ctx.MkApp(Constdecls[i]); _consts[i] = ctx.MkApp(_constdecls[i]);
} }
}; };
@ -513,7 +517,7 @@ package com.Microsoft.Z3;
/** /**
* The arity of the relation sort. * The arity of the relation sort.
**/ **/
public Integer Arity() { return Native.getRelationArity(Context.nCtx, NativeObject); } public long Arity() { return Native.getRelationArity(Context.nCtx, NativeObject); }
/** /**
* The sorts of the columns of the relation sort. * The sorts of the columns of the relation sort.
@ -522,17 +526,17 @@ package com.Microsoft.Z3;
{ {
if (mColumnSorts != null) if (m_columnSorts != null)
return mColumnSorts; return m_columnSorts;
Integer n = Arity; long n = Arity;
Sort[] res = new Sort[n]; Sort[] res = new Sort[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Sort.Create(Context, Native.getRelationColumn(Context.nCtx, NativeObject, i)); res[i] = Sort.Create(Context, Native.getRelationColumn(Context.nCtx, NativeObject, i));
return res; return res;
} }
private Sort[] mColumnSorts = null; private Sort[] m_columnSorts = null;
RelationSort(Context ctx, IntPtr obj) RelationSort(Context ctx, IntPtr obj)
{ super(ctx, obj); { super(ctx, obj);

View file

@ -23,19 +23,19 @@ package com.Microsoft.Z3;
/** /**
* The uint-value of the entry. * The uint-value of the entry.
**/ **/
public Integer UIntValue() { return mInteger; } public long UIntValue() { return m_long; }
/** /**
* The double-value of the entry. * The double-value of the entry.
**/ **/
public double DoubleValue() { return mDouble; } public double DoubleValue() { return m_double; }
/** /**
* True if the entry is uint-valued. * True if the entry is uint-valued.
**/ **/
public boolean IsUInt() { return mIsInteger; } public boolean IsUInt() { return m_is_long; }
/** /**
* True if the entry is double-valued. * True if the entry is double-valued.
**/ **/
public boolean IsDouble() { return mIsDouble; } public boolean IsDouble() { return m_is_double; }
/** /**
* The string representation of the the entry's value. * The string representation of the the entry's value.
@ -45,9 +45,9 @@ package com.Microsoft.Z3;
if (IsUInt) if (IsUInt)
return mInteger.toString(); return m_long.toString();
else if (IsDouble) else if (IsDouble)
return mDouble.toString(); return m_double.toString();
else else
throw new Z3Exception("Unknown statistical entry type"); throw new Z3Exception("Unknown statistical entry type");
} }
@ -60,12 +60,12 @@ package com.Microsoft.Z3;
return Key + ": " + Value; return Key + ": " + Value;
} }
private boolean mIsInteger = false; private boolean m_is_long = false;
private boolean mIsDouble = false; private boolean m_is_double = false;
private Integer mInteger = 0; private long m_long = 0;
private double mDouble = 0.0; private double m_double = 0.0;
Entry(String k, Integer v) { Key = k; mIsInteger = true; mInteger = v; } Entry(String k, long v) { Key = k; m_is_long = true; m_long = v; }
Entry(String k, double v) { Key = k; mIsDouble = true; mDouble = v; } Entry(String k, double v) { Key = k; m_is_double = true; m_double = v; }
} }
/** /**
@ -79,7 +79,7 @@ package com.Microsoft.Z3;
/** /**
* The number of statistical data. * The number of statistical data.
**/ **/
public Integer Size() { return Native.statsSize(Context.nCtx, NativeObject); } public long Size() { return Native.statsSize(Context.nCtx, NativeObject); }
/** /**
* The data entries. * The data entries.
@ -90,21 +90,21 @@ package com.Microsoft.Z3;
Integer n = Size; long n = Size;
Entry[] res = new Entry[n]; Entry[] res = new Entry[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
{ {
Entry e; Entry e;
String k = Native.statsGetKey(Context.nCtx, NativeObject, i); String k = Native.statsGetKey(Context.nCtx, NativeObject, i);
if (Native.statsIsInteger(Context.nCtx, NativeObject, i) != 0) if (Native.statsIsLong(Context.nCtx, NativeObject, i) != 0)
e = new Entry(k, Native.statsGetIntegerValue(Context.nCtx, NativeObject, i)); e = new Entry(k, Native.statsGetLongValue(Context.nCtx, NativeObject, i));
else if (Native.statsIsDouble(Context.nCtx, NativeObject, i) != 0) else if (Native.statsIsDouble(Context.nCtx, NativeObject, i) != 0)
e = new Entry(k, Native.statsGetDoubleValue(Context.nCtx, NativeObject, i)); e = new Entry(k, Native.statsGetDoubleValue(Context.nCtx, NativeObject, i));
else else
throw new Z3Exception("Unknown data entry value"); throw new Z3Exception("Unknown data entry value");
res[i] = e; res[i] = e;
return res;
} }
return res;
} }
/** /**
@ -114,9 +114,9 @@ package com.Microsoft.Z3;
{ {
Integer n = Size; long n = Size;
String[] res = new String[n]; String[] res = new String[n];
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
res[i] = Native.statsGetKey(Context.nCtx, NativeObject, i); res[i] = Native.statsGetKey(Context.nCtx, NativeObject, i);
return res; return res;
} }
@ -125,11 +125,11 @@ package com.Microsoft.Z3;
* The value of a particular statistical counter. * The value of a particular statistical counter.
* <remarks>Returns null if the key is unknown.</remarks> * <remarks>Returns null if the key is unknown.</remarks>
**/ **/
public Entry this[String key]() public Entry get(String key)
{ {
Integer n = Size; long n = Size;
Entry[] es = Entries; Entry[] es = Entries;
for (Integer i = 0; i < n; i++) for (long i = 0; i < n; i++)
if (es[i].Key == key) if (es[i].Key == key)
return es[i]; return es[i];
return null; return null;
@ -155,13 +155,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.StatisticsDRQ.IncAndClear(Context, o); Context.Statistics_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.StatisticsDRQ.Add(o); Context.Statistics_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -15,9 +15,9 @@ package com.Microsoft.Z3;
/** /**
* The kind of the symbol (int or string) * The kind of the symbol (int or string)
**/ **/
protected Z3SymbolKind Kind protected Z3_symbol_kind Kind
{ {
get { return (Z3SymbolKind)Native.getSymbolKind(Context.nCtx, NativeObject); } get { return (Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, NativeObject); }
} }
/** /**
@ -25,7 +25,7 @@ package com.Microsoft.Z3;
**/ **/
public boolean IsIntSymbol() public boolean IsIntSymbol()
{ {
return Kind == Z3SymbolKind.Z3INTSYMBOL; return Kind == Z3_symbol_kind.Z3_INT_SYMBOL;
} }
/** /**
@ -33,7 +33,7 @@ package com.Microsoft.Z3;
**/ **/
public boolean IsStringSymbol() public boolean IsStringSymbol()
{ {
return Kind == Z3SymbolKind.Z3STRINGSYMBOL; return Kind == Z3_symbol_kind.Z3_STRING_SYMBOL;
} }
/** /**
@ -61,10 +61,10 @@ package com.Microsoft.Z3;
switch ((Z3SymbolKind)Native.getSymbolKind(ctx.nCtx, obj)) switch ((Z3_symbol_kind)Native.getSymbolKind(ctx.nCtx, obj))
{ {
case Z3SymbolKind.Z3INTSYMBOL: return new IntSymbol(ctx, obj); case Z3_symbol_kind.Z3_INT_SYMBOL: return new IntSymbol(ctx, obj);
case Z3SymbolKind.Z3STRINGSYMBOL: return new StringSymbol(ctx, obj); case Z3_symbol_kind.Z3_STRING_SYMBOL: return new StringSymbol(ctx, obj);
default: default:
throw new Z3Exception("Unknown symbol kind encountered"); throw new Z3Exception("Unknown symbol kind encountered");
} }
@ -98,7 +98,7 @@ package com.Microsoft.Z3;
void CheckNativeObject(IntPtr obj) void CheckNativeObject(IntPtr obj)
{ {
if ((Z3SymbolKind)Native.getSymbolKind(Context.nCtx, obj) != Z3SymbolKind.Z3INTSYMBOL) if ((Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, obj) != Z3_symbol_kind.Z3_INT_SYMBOL)
throw new Z3Exception("Symbol is not of integer kind"); throw new Z3Exception("Symbol is not of integer kind");
super.CheckNativeObject(obj); super.CheckNativeObject(obj);
} }
@ -132,7 +132,7 @@ package com.Microsoft.Z3;
void CheckNativeObject(IntPtr obj) void CheckNativeObject(IntPtr obj)
{ {
if ((Z3SymbolKind)Native.getSymbolKind(Context.nCtx, obj) != Z3SymbolKind.Z3STRINGSYMBOL) if ((Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, obj) != Z3_symbol_kind.Z3_STRING_SYMBOL)
throw new Z3Exception("Symbol is not of String kind"); throw new Z3Exception("Symbol is not of String kind");
super.CheckNativeObject(obj); super.CheckNativeObject(obj);

View file

@ -52,7 +52,7 @@ package com.Microsoft.Z3;
/** /**
* Apply the tactic to a goal. * Apply the tactic to a goal.
**/ **/
public ApplyResult this[Goal g]() public ApplyResult get(Goal g)
{ {
@ -95,13 +95,13 @@ package com.Microsoft.Z3;
void IncRef(IntPtr o) void IncRef(IntPtr o)
{ {
Context.TacticDRQ.IncAndClear(Context, o); Context.Tactic_DRQ.IncAndClear(Context, o);
super.IncRef(o); super.IncRef(o);
} }
void DecRef(IntPtr o) void DecRef(IntPtr o)
{ {
Context.TacticDRQ.Add(o); Context.Tactic_DRQ.Add(o);
super.DecRef(o); super.DecRef(o);
} }
} }

View file

@ -17,9 +17,9 @@ package com.Microsoft.Z3;
/** /**
* The major version * The major version
**/ **/
public Integer Major() public long Major()
{ {
Integer major = 0, minor = 0, build = 0, revision = 0; long major = 0, minor = 0, build = 0, revision = 0;
Native.getVersion(major, minor, build, revision); Native.getVersion(major, minor, build, revision);
return major; return major;
} }
@ -27,9 +27,9 @@ package com.Microsoft.Z3;
/** /**
* The minor version * The minor version
**/ **/
public Integer Minor() public long Minor()
{ {
Integer major = 0, minor = 0, build = 0, revision = 0; long major = 0, minor = 0, build = 0, revision = 0;
Native.getVersion(major, minor, build, revision); Native.getVersion(major, minor, build, revision);
return minor; return minor;
} }
@ -37,9 +37,9 @@ package com.Microsoft.Z3;
/** /**
* The build version * The build version
**/ **/
public Integer Build() public long Build()
{ {
Integer major = 0, minor = 0, build = 0, revision = 0; long major = 0, minor = 0, build = 0, revision = 0;
Native.getVersion(major, minor, build, revision); Native.getVersion(major, minor, build, revision);
return build; return build;
} }
@ -47,9 +47,9 @@ package com.Microsoft.Z3;
/** /**
* The revision * The revision
**/ **/
public Integer Revision() public long Revision()
{ {
Integer major = 0, minor = 0, build = 0, revision = 0; long major = 0, minor = 0, build = 0, revision = 0;
Native.getVersion(major, minor, build, revision); Native.getVersion(major, minor, build, revision);
return revision; return revision;
} }
@ -61,7 +61,7 @@ package com.Microsoft.Z3;
{ {
Integer major = 0, minor = 0, build = 0, revision = 0; long major = 0, minor = 0, build = 0, revision = 0;
Native.getVersion(major, minor, build, revision); Native.getVersion(major, minor, build, revision);
return major.toString() + "." + minor.toString() + "." + build.toString() + "." + revision.toString(); return major.toString() + "." + minor.toString() + "." + build.toString() + "." + revision.toString();
} }

View file

@ -25,18 +25,18 @@ package com.Microsoft.Z3;
**/ **/
public void Dispose() public void Dispose()
{ {
if (mNObj != IntPtr.Zero) if (m_n_obj != IntPtr.Zero)
{ {
DecRef(mNObj); DecRef(m_n_obj);
mNObj = IntPtr.Zero; m_n_obj = IntPtr.Zero;
} }
if (mCtx != null) if (m_ctx != null)
{ {
mCtx.refCount--; m_ctx.refCount--;
if (mCtx.refCount == 0) if (m_ctx.refCount == 0)
GC.ReRegisterForFinalize(mCtx); GC.ReRegisterForFinalize(m_ctx);
mCtx = null; m_ctx = null;
} }
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -49,15 +49,15 @@ package com.Microsoft.Z3;
} }
private Context mCtx = null; private Context m_ctx = null;
private IntPtr mNObj = IntPtr.Zero; private IntPtr m_n_obj = IntPtr.Zero;
Z3Object(Context ctx) Z3Object(Context ctx)
{ {
ctx.refCount++; ctx.refCount++;
mCtx = ctx; m_ctx = ctx;
} }
Z3Object(Context ctx, IntPtr obj) Z3Object(Context ctx, IntPtr obj)
@ -65,9 +65,9 @@ package com.Microsoft.Z3;
ctx.refCount++; ctx.refCount++;
mCtx = ctx; m_ctx = ctx;
IncRef(obj); IncRef(obj);
mNObj = obj; m_n_obj = obj;
} }
void IncRef(IntPtr o) { } void IncRef(IntPtr o) { }
@ -77,12 +77,12 @@ package com.Microsoft.Z3;
IntPtr NativeObject IntPtr NativeObject
{ {
get { return mNObj; } get { return m_n_obj; }
set set
{ {
if (value != IntPtr.Zero) { CheckNativeObject(value); IncRef(value); } if (value != IntPtr.Zero) { CheckNativeObject(value); IncRef(value); }
if (mNObj != IntPtr.Zero) { DecRef(mNObj); } if (m_n_obj != IntPtr.Zero) { DecRef(m_n_obj); }
mNObj = value; m_n_obj = value;
} }
} }
@ -97,7 +97,7 @@ package com.Microsoft.Z3;
get get
{ {
return mCtx; return m_ctx;
} }
} }
@ -108,13 +108,13 @@ package com.Microsoft.Z3;
if (a == null) return null; if (a == null) return null;
IntPtr[] an = new IntPtr[a.Length]; IntPtr[] an = new IntPtr[a.Length];
for (Integer i = 0; i < a.Length; i++) for (long i = 0; i < a.Length; i++)
if (a[i] != null) an[i] = a[i].NativeObject; if (a[i] != null) an[i] = a[i].NativeObject;
return an; return an;
} }
static Integer ArrayLength(Z3Object[] a) static long ArrayLength(Z3Object[] a)
{ {
return (a == null)?0:(Integer)a.Length; return (a == null)?0:(long)a.Length;
} }
} }

View file

@ -30,14 +30,22 @@ def subst_getters(s, getters):
def type_replace(s): def type_replace(s):
s = s.replace("bool", "boolean") s = s.replace("bool", "boolean")
s = s.replace("uint", "Integer") s = s.replace("uint", "long")
s = s.replace("string", "String") s = s.replace("string", "String")
return s return s
def rename_native(s): def rename_native(s):
a = re.sub("Native.Z3_(?P<id>\w+)", "Native.\g<id>", s) while s.find("Native.Z3") != -1:
i0 = s.find("Native.Z3")
i1 = s.find("(", i0)
c0 = s[:i0]
c1 = s[i0:i1]
c1 = c1.replace("Native.Z3_", "Native.")
c2 = s[i1:]
lc_callback = lambda pat: pat.group("id").upper() lc_callback = lambda pat: pat.group("id").upper()
return re.sub("_(?P<id>\w)", lc_callback, a) c1 = re.sub("_(?P<id>\w)", lc_callback, c1)
s = c0 + c1 + c2
return s
def translate(filename): def translate(filename):
@ -54,6 +62,9 @@ def translate(filename):
in_getter_type = "" in_getter_type = ""
in_unsupported = 0 in_unsupported = 0
getters = [] getters = []
in_bracket_op = 0
in_getter_get = 0
in_getter_set = 0
for line in fileinput.input(os.path.join(CS, filename)): for line in fileinput.input(os.path.join(CS, filename)):
s = string.rstrip(string.lstrip(line)) s = string.rstrip(string.lstrip(line))
if in_javadoc: if in_javadoc:
@ -97,19 +108,19 @@ def translate(filename):
tgt.write("/* " + s + " */\n") tgt.write("/* " + s + " */\n")
elif s.startswith("namespace"): elif s.startswith("namespace"):
pass pass
elif s.startswith("public") and s.find("operator") and (s.find("==") != -1 or s.find("!=") != -1): elif s.startswith("public") and s.find("operator") != -1 and (s.find("==") != -1 or s.find("!=") != -1):
t = "" t = ""
for i in range(0, line.find(s)+1): for i in range(0, line.find(s)+1):
t += " " t += " "
tgt.write(t + "/* Overloaded operators are not translated. */\n") tgt.write(t + "/* Overloaded operators are not translated. */\n")
in_unsupported = 1; in_unsupported = 1;
elif s.startswith("public class") or s.startswith("internal class"): elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"):
a = line.replace(":", "extends").replace("internal ", "") a = line.replace(":", "extends").replace("internal ", "")
a = a.replace(", IComparable", "") a = a.replace(", IComparable", "")
tgt.write(a) tgt.write(a)
in_class = 1 in_class = 1
in_static_class = 0 in_static_class = 0
elif s.startswith("public static class"): elif s.startswith("public static class") or s.startswith("abstract class"):
tgt.write(line.replace(":", "extends").replace("static", "final")) tgt.write(line.replace(":", "extends").replace("static", "final"))
in_class = 1 in_class = 1
in_static_class = 1 in_static_class = 1
@ -119,8 +130,9 @@ def translate(filename):
elif skip_brace and s == "{": elif skip_brace and s == "{":
skip_brace = 0 skip_brace = 0
elif s.find("public") != -1 and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1: elif s.find("public") != -1 and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1:
if (s.startswith("new")):
s = s[3:]
tokens = s.split(" ") tokens = s.split(" ")
print "# TOKENS: " + str(len(tokens))
if len(tokens) == 3: if len(tokens) == 3:
in_getter = tokens[2] in_getter = tokens[2]
in_getter_type = type_replace((tokens[0] + " " + tokens[1])) in_getter_type = type_replace((tokens[0] + " " + tokens[1]))
@ -129,6 +141,12 @@ def translate(filename):
lastindent = line.find(s) lastindent = line.find(s)
skip_brace = 1 skip_brace = 1
elif len(tokens) == 4: elif len(tokens) == 4:
if tokens[2].startswith("this["):
in_bracket_op = 1
in_getter = type_replace(tokens[2]).replace("this[", "get(")
in_getter += " " + tokens[3].replace("]", ")")
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
else:
in_getter = tokens[3] in_getter = tokens[3]
in_getter_type = type_replace(tokens[0] + " " + tokens[1] + " " + tokens[2]) in_getter_type = type_replace(tokens[0] + " " + tokens[1] + " " + tokens[2])
if in_static_class: if in_static_class:
@ -156,8 +174,12 @@ def translate(filename):
d = line[0:line.find("{ get")] d = line[0:line.find("{ get")]
rest = line[line.find("{ get")+5:] rest = line[line.find("{ get")+5:]
rest = rest.replace("} }", "}") rest = rest.replace("} }", "}")
rest = re.sub("Contract.\w+\([\s\S]*\);", "", rest)
subst_getters(rest, getters) subst_getters(rest, getters)
rest = rename_native(rest) rest = rename_native(rest)
if in_bracket_op:
tgt.write(d + rest)
else:
tgt.write(d + "()" + rest) tgt.write(d + "()" + rest)
print "ACC: " + s + " --> " + in_getter print "ACC: " + s + " --> " + in_getter
elif in_getter != "" and s.startswith("get"): elif in_getter != "" and s.startswith("get"):
@ -169,7 +191,12 @@ def translate(filename):
subst_getters(rest, getters) subst_getters(rest, getters)
rest = type_replace(rest) rest = type_replace(rest)
rest = rename_native(rest) rest = rename_native(rest)
if in_bracket_op:
tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n")
else:
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n") tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
if rest.find("}") == -1:
in_getter_get = 1
elif in_getter != "" and s.startswith("set"): elif in_getter != "" and s.startswith("set"):
t = "" t = ""
for i in range(0, lastindent): for i in range(0, lastindent):
@ -182,10 +209,23 @@ def translate(filename):
rest = rename_native(rest) rest = rename_native(rest)
ac_acc = in_getter_type[:in_getter_type.find(' ')] ac_acc = in_getter_type[:in_getter_type.find(' ')]
ac_type = in_getter_type[in_getter_type.find(' ')+1:] ac_type = in_getter_type[in_getter_type.find(' ')+1:]
if in_bracket_op:
in_getter = in_getter.replace("get", "set").replace(")", "")
tgt.write(t + ac_acc + " void " + in_getter + ", " + ac_type + " value) " + rest + "\n")
else:
tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n") tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n")
elif in_getter != "" and s == "}": if rest.find("}") == -1:
in_getter_set = 1
elif in_getter != "" and in_getter_get and s == "}":
tgt.write(line)
in_getter_get = 0
elif in_getter != "" and in_getter_set and s == "}":
tgt.write(line)
in_getter_set = 0
elif in_getter != "" and not in_getter_get and not in_getter_set and s == "}":
in_getter = "" in_getter = ""
in_getter_type == "" in_getter_type == ""
in_bracket_op = 0
skip_brace = 0 skip_brace = 0
elif s.startswith("uint ") and s.find("=") == -1: elif s.startswith("uint ") and s.find("=") == -1:
line = line.replace("uint", "Integer", line) line = line.replace("uint", "Integer", line)
@ -206,22 +246,28 @@ def translate(filename):
skip_brace = 1 skip_brace = 1
if s.startswith("public"): if s.startswith("public"):
line = re.sub(" = [\w.]+(?P<d>[,;\)])", "\g<d>", line) line = re.sub(" = [\w.]+(?P<d>[,;\)])", "\g<d>", line)
line = re.sub("(?P<d>[\(, ])params ", "\g<d>", line)
line = line.replace("base.", "super.")
a = type_replace(line) a = type_replace(line)
a = re.sub("(?P<d>[\(, ])params ", "\g<d>", a)
a = a.replace("base.", "super.")
a = re.sub("Contract.\w+\([\s\S]*\);", "", a) a = re.sub("Contract.\w+\([\s\S]*\);", "", a)
a = rename_native(a) a = rename_native(a)
a = re.sub("~\w+\(\)", "protected void finalize()", a) a = re.sub("~\w+\(\)", "protected void finalize()", a)
a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)", a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
"for (\g<t>.Iterator \g<i> = \g<w>.iterator(); \g<i>.hasNext(); )", a) "for (\g<t>.Iterator \g<i> = \g<w>.iterator(); \g<i>.hasNext(); )", a)
a = a.replace("readonly private", "private") a = a.replace("readonly ", "")
a = a.replace("new public", "public") a = a.replace("const ", "final ")
a = a.replace("ToString", "toString") a = a.replace("ToString", "toString")
a = a.replace("internal ", "") a = a.replace("internal ", "")
a = a.replace("new static", "static")
a = a.replace("new public", "public")
a = a.replace("override ", "") a = a.replace("override ", "")
a = a.replace("virtual ", "") a = a.replace("virtual ", "")
a = a.replace("o as AST", "(AST) o") a = a.replace("o as AST", "(AST) o")
a = a.replace("other as AST", "(AST) other") a = a.replace("other as AST", "(AST) other")
a = a.replace("o as FuncDecl", "(FuncDecl) o")
a = a.replace("IntPtr res = IntPtr.Zero;", "Native.IntPtr res = new Native.IntPtr();")
a = a.replace("out res", "res")
a = a.replace("lock (", "synchronized (")
if in_static_class: if in_static_class:
a = a.replace("static", "") a = a.replace("static", "")
a = re.sub("ref (?P<id>\w+)", "\g<id>", a) a = re.sub("ref (?P<id>\w+)", "\g<id>", a)