3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00

Improved memory use of the Java API. Thanks to Joerg Pfaehler for reporting this issue!

+ formatting

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2015-01-30 21:04:18 -06:00
parent 3b78509d0a
commit d7a62baef4
60 changed files with 3149 additions and 2992 deletions

View file

@ -22,53 +22,53 @@ package com.microsoft.z3;
**/
public class Constructor extends Z3Object
{
/**
* The number of fields of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
* @return an int
**/
public int getNumFields() throws Z3Exception
{
return n;
}
/**
* The number of fields of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
* @return an int
**/
public int getNumFields() throws Z3Exception
{
return n;
}
/**
* The function declaration of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl ConstructorDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
/**
* The function declaration of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl ConstructorDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
return new FuncDecl(getContext(), constructor.value);
}
}
/**
* The function declaration of the tester.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl getTesterDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
/**
* The function declaration of the tester.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl getTesterDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
return new FuncDecl(getContext(), tester.value);
}
}
/**
* The function declarations of the accessors
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[] getAccessorDecls() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
/**
* The function declarations of the accessors
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[] getAccessorDecls() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
@ -76,40 +76,40 @@ public class Constructor extends Z3Object
for (int i = 0; i < n; i++)
t[i] = new FuncDecl(getContext(), accessors[i]);
return t;
}
}
/**
* Destructor.
* @throws Z3Exception on error
**/
protected void finalize() throws Z3Exception
{
Native.delConstructor(getContext().nCtx(), getNativeObject());
}
/**
* Destructor.
* @throws Z3Exception on error
**/
protected void finalize() throws Z3Exception
{
Native.delConstructor(getContext().nCtx(), getNativeObject());
}
private int n = 0;
private int n = 0;
Constructor(Context ctx, Symbol name, Symbol recognizer,
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
throws Z3Exception
{
super(ctx);
Constructor(Context ctx, Symbol name, Symbol recognizer,
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
throws Z3Exception
{
super(ctx);
n = AST.arrayLength(fieldNames);
n = AST.arrayLength(fieldNames);
if (n != AST.arrayLength(sorts))
throw new Z3Exception(
"Number of field names does not match number of sorts");
if (sortRefs != null && sortRefs.length != n)
throw new Z3Exception(
"Number of field names does not match number of sort refs");
if (n != AST.arrayLength(sorts))
throw new Z3Exception(
"Number of field names does not match number of sorts");
if (sortRefs != null && sortRefs.length != n)
throw new Z3Exception(
"Number of field names does not match number of sort refs");
if (sortRefs == null)
sortRefs = new int[n];
if (sortRefs == null)
sortRefs = new int[n];
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
Sort.arrayToNative(sorts), sortRefs));
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
Sort.arrayToNative(sorts), sortRefs));
}
}
}