mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +00:00
99 lines
2.5 KiB
C#
99 lines
2.5 KiB
C#
/*++
|
|
Copyright (c) 2012 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
Parameter.cs
|
|
|
|
Abstract:
|
|
|
|
Z3 Managed API: Parameter Descriptions
|
|
|
|
Author:
|
|
|
|
Christoph Wintersteiger (cwinter) 2012-03-20
|
|
|
|
Notes:
|
|
|
|
--*/
|
|
|
|
using System;
|
|
using System.Diagnostics.Contracts;
|
|
|
|
namespace Microsoft.Z3
|
|
{
|
|
/// <summary>
|
|
/// A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
|
/// </summary>
|
|
[ContractVerification(true)]
|
|
public class ParamDescrs : Z3Object
|
|
{
|
|
/// <summary>
|
|
/// validate a set of parameters.
|
|
/// </summary>
|
|
public void Validate(Params p)
|
|
{
|
|
Contract.Requires(p != null);
|
|
Native.Z3_params_validate(Context.nCtx, p.NativeObject, NativeObject);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve kind of parameter.
|
|
/// </summary>
|
|
public Z3_param_kind GetKind(Symbol name)
|
|
{
|
|
Contract.Requires(name != null);
|
|
return (Z3_param_kind)Native.Z3_param_descrs_get_kind(Context.nCtx, NativeObject, name.NativeObject);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve all names of parameters.
|
|
/// </summary>
|
|
public Symbol[] Names
|
|
{
|
|
get
|
|
{
|
|
uint sz = Native.Z3_param_descrs_size(Context.nCtx, NativeObject);
|
|
Symbol[] names = new Symbol[sz];
|
|
for (uint i = 0; i < sz; ++i) {
|
|
names[i] = Symbol.Create(Context, Native.Z3_param_descrs_get_name(Context.nCtx, NativeObject, i));
|
|
}
|
|
return names;
|
|
}
|
|
}
|
|
|
|
#region Internal
|
|
internal ParamDescrs(Context ctx, IntPtr obj)
|
|
: base(ctx, obj)
|
|
{
|
|
Contract.Requires(ctx != null);
|
|
}
|
|
|
|
internal class DecRefQueue : Z3.DecRefQueue
|
|
{
|
|
public override void IncRef(Context ctx, IntPtr obj)
|
|
{
|
|
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
|
|
}
|
|
|
|
public override void DecRef(Context ctx, IntPtr obj)
|
|
{
|
|
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
|
|
}
|
|
};
|
|
|
|
internal override void IncRef(IntPtr o)
|
|
{
|
|
Context.ParamDescrs_DRQ.IncAndClear(Context, o);
|
|
base.IncRef(o);
|
|
}
|
|
|
|
internal override void DecRef(IntPtr o)
|
|
{
|
|
Context.ParamDescrs_DRQ.Add(o);
|
|
base.DecRef(o);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|