mirror of
https://github.com/Z3Prover/z3
synced 2025-06-14 01:46:15 +00:00
Added finite domain expressions and numerals to the .NET, Java, and Python APIs.
Relates to #318
This commit is contained in:
parent
9e756fb6db
commit
cbda38ee80
10 changed files with 380 additions and 12 deletions
|
@ -2165,6 +2165,8 @@ public class Expr extends AST
|
|||
return new FPNum(ctx, obj);
|
||||
case Z3_ROUNDING_MODE_SORT:
|
||||
return new FPRMNum(ctx, obj);
|
||||
case Z3_FINITE_DOMAIN_SORT:
|
||||
return new FiniteDomainNum(ctx, obj);
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
@ -2187,6 +2189,8 @@ public class Expr extends AST
|
|||
return new FPExpr(ctx, obj);
|
||||
case Z3_ROUNDING_MODE_SORT:
|
||||
return new FPRMExpr(ctx, obj);
|
||||
case Z3_FINITE_DOMAIN_SORT:
|
||||
return new FiniteDomainExpr(ctx, obj);
|
||||
default: ;
|
||||
}
|
||||
|
||||
|
|
33
src/api/java/FiniteDomainExpr.java
Normal file
33
src/api/java/FiniteDomainExpr.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FiniteDomainExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2015-12-02
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Finite-domain expressions
|
||||
**/
|
||||
public class FiniteDomainExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for FiniteDomainExpr
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
FiniteDomainExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
76
src/api/java/FiniteDomainNum.java
Normal file
76
src/api/java/FiniteDomainNum.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
Copyright (c) 2012-2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FiniteDomainNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2015-12-02
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Finite-domain Numerals
|
||||
**/
|
||||
public class FiniteDomainNum extends FiniteDomainExpr
|
||||
{
|
||||
|
||||
FiniteDomainNum(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the int value.
|
||||
**/
|
||||
public int getInt()
|
||||
{
|
||||
Native.IntPtr res = new Native.IntPtr();
|
||||
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the 64-bit int value.
|
||||
**/
|
||||
public long getInt64()
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the BigInteger value.
|
||||
**/
|
||||
public BigInteger getBigInteger()
|
||||
{
|
||||
return new BigInteger(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the numeral.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue