3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 20:05:51 +00:00

Made DRQ objects public in Java and .NET APIs.

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2015-01-30 21:58:43 -06:00
parent 07c945718b
commit 4bed5183f8
32 changed files with 182 additions and 109 deletions

View file

@ -215,12 +215,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_dec_ref(ctx.nCtx, obj);
}

View file

@ -130,12 +130,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_dec_ref(ctx.nCtx, obj);
}

View file

@ -107,12 +107,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_dec_ref(ctx.nCtx, obj);
}

View file

@ -87,12 +87,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_dec_ref(ctx.nCtx, obj);
}

View file

@ -4411,21 +4411,80 @@ namespace Microsoft.Z3
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(10);
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(10);
internal AST.DecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
internal ASTMap.DecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
internal ASTVector.DecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
internal ApplyResult.DecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
internal FuncInterp.Entry.DecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
internal FuncInterp.DecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
internal Goal.DecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
internal Model.DecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
internal Params.DecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
internal ParamDescrs.DecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
internal Probe.DecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
internal Solver.DecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
internal Statistics.DecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
internal Tactic.DecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
/// <summary>
/// AST DRQ
/// </summary>
public IDecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
/// <summary>
/// ASTMap DRQ
/// </summary>
public IDecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
/// <summary>
/// ASTVector DRQ
/// </summary>
public IDecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
/// <summary>
/// ApplyResult DRQ
/// </summary>
public IDecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
/// <summary>
/// FuncEntry DRQ
/// </summary>
public IDecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
/// <summary>
/// FuncInterp DRQ
/// </summary>
public IDecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
/// <summary>
/// Goal DRQ
/// </summary>
public IDecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
/// <summary>
/// Model DRQ
/// </summary>
public IDecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
/// <summary>
/// Params DRQ
/// </summary>
public IDecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
/// <summary>
/// ParamDescrs DRQ
/// </summary>
public IDecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
/// <summary>
/// Probe DRQ
/// </summary>
public IDecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
/// <summary>
/// Solver DRQ
/// </summary>
public IDecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
/// <summary>
/// Statistics DRQ
/// </summary>
public IDecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
/// <summary>
/// Tactic DRQ
/// </summary>
public IDecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
/// <summary>
/// FixedPoint DRQ
/// </summary>
public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal long refCount = 0;

View file

@ -337,12 +337,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_dec_ref(ctx.nCtx, obj);
}

View file

@ -93,12 +93,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_dec_ref(ctx.nCtx, obj);
}
@ -201,12 +201,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_dec_ref(ctx.nCtx, obj);
}

View file

@ -221,12 +221,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_dec_ref(ctx.nCtx, obj);
}

View file

@ -25,8 +25,11 @@ using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// DecRefQueue interface
/// </summary>
[ContractClass(typeof(DecRefQueueContracts))]
internal abstract class IDecRefQueue
public abstract class IDecRefQueue
{
#region Object invariant
@ -38,19 +41,25 @@ namespace Microsoft.Z3
#endregion
readonly internal protected Object m_lock = new Object();
readonly internal protected List<IntPtr> m_queue = new List<IntPtr>();
internal uint m_move_limit;
readonly private Object m_lock = new Object();
readonly private List<IntPtr> m_queue = new List<IntPtr>();
private uint m_move_limit;
public IDecRefQueue(uint move_limit = 1024)
internal IDecRefQueue(uint move_limit = 1024)
{
m_move_limit = move_limit;
}
public abstract void IncRef(Context ctx, IntPtr obj);
public abstract void DecRef(Context ctx, IntPtr obj);
/// <summary>
/// Sets the limit on numbers of objects that are kept back at GC collection.
/// </summary>
/// <param name="l"></param>
public void SetLimit(uint l) { m_move_limit = l; }
public void IncAndClear(Context ctx, IntPtr o)
internal abstract void IncRef(Context ctx, IntPtr obj);
internal abstract void DecRef(Context ctx, IntPtr obj);
internal void IncAndClear(Context ctx, IntPtr o)
{
Contract.Requires(ctx != null);
@ -58,7 +67,7 @@ namespace Microsoft.Z3
if (m_queue.Count >= m_move_limit) Clear(ctx);
}
public void Add(IntPtr o)
internal void Add(IntPtr o)
{
if (o == IntPtr.Zero) return;
@ -68,7 +77,7 @@ namespace Microsoft.Z3
}
}
public void Clear(Context ctx)
internal void Clear(Context ctx)
{
Contract.Requires(ctx != null);
@ -84,12 +93,12 @@ namespace Microsoft.Z3
[ContractClassFor(typeof(IDecRefQueue))]
abstract class DecRefQueueContracts : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}

View file

@ -293,12 +293,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_model_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_model_dec_ref(ctx.nCtx, obj);
}

View file

@ -89,12 +89,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
}

View file

@ -142,12 +142,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_params_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_params_dec_ref(ctx.nCtx, obj);
}

View file

@ -75,12 +75,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_dec_ref(ctx.nCtx, obj);
}

View file

@ -330,12 +330,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_dec_ref(ctx.nCtx, obj);
}

View file

@ -191,12 +191,12 @@ namespace Microsoft.Z3
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_dec_ref(ctx.nCtx, obj);
}

View file

@ -112,16 +112,19 @@ namespace Microsoft.Z3
Contract.Requires(ctx != null);
}
/// <summary>
/// DecRefQueue
/// </summary>
internal class DecRefQueue : IDecRefQueue
{
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_dec_ref(ctx.nCtx, obj);
}