3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-26 10:35:33 +00:00

Added accessors to enumeration sorts. Thanks to codeplex user steimann for suggesting this.

(http://z3.codeplex.com/workitem/195)

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2015-03-24 21:42:05 +00:00
parent b76d588c28
commit 1c77ad00c3
5 changed files with 87 additions and 4 deletions

View file

@ -34,11 +34,20 @@ public class EnumSort extends Sort
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), i));
return t;
}
/**
* Retrieves the inx'th constant declaration in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl getConstDecl(int inx) throws Z3Exception
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), inx));
}
/**
* The constants in the enumeration.
* @throws Z3Exception on error
* @return an Expr
* @return an Expr[]
**/
public Expr[] getConsts() throws Z3Exception
{
@ -48,6 +57,16 @@ public class EnumSort extends Sort
t[i] = getContext().mkApp(cds[i]);
return t;
}
/**
* Retrieves the inx'th constant in the enumeration.
* @throws Z3Exception on error
* @return an Expr
**/
public Expr getConst(int inx) throws Z3Exception
{
return getContext().mkApp(getConstDecl(inx));
}
/**
* The test predicates for the constants in the enumeration.
@ -61,6 +80,15 @@ public class EnumSort extends Sort
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), i));
return t;
}
/**
* Retrieves the inx'th tester/recognizer declaration in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl getTesterDecl(int inx) throws Z3Exception
{
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), inx));
}
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
{