mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 10:55:50 +00:00
Managed API: Refactoring and formatting.
Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
parent
edc9dccbcf
commit
7defd469bb
52 changed files with 2006 additions and 1657 deletions
115
src/api/dotnet/BitVecNum.cs
Normal file
115
src/api/dotnet/BitVecNum.cs
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
IntNum.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Int Numerals
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-20
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
using System.Numerics;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Bit-vector numerals
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class BitVecNum : BitVecExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit unsigned integer value.
|
||||
/// </summary>
|
||||
public UInt64 UInt64
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public int Int
|
||||
{
|
||||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit int value.
|
||||
/// </summary>
|
||||
public Int64 Int64
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public uint UInt
|
||||
{
|
||||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
/// <summary>
|
||||
/// Retrieve the BigInteger value.
|
||||
/// </summary>
|
||||
public BigInteger BigInteger
|
||||
{
|
||||
get
|
||||
{
|
||||
return BigInteger.Parse(this.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue