mirror of
https://github.com/Z3Prover/z3
synced 2026-01-12 05:36:16 +00:00
* Reworked phantom reference handling. - Replaced IDecRefQueue with a new Z3ReferenceQueue class - Z3ReferenceQueue manages custom subclasses of phantom references in a doubly-linked list - Replaced all subclasses of IDecRefQueue with subclasses of Z3ReferenceQueue.Reference. These custom reference classes are embedded in the class they reference count. - Context now owns a single Z3ReferenceQueue for all types of references. * Made Statistics.Entry a static subclass * Made Context.close idempotent (as recommended) * Update CMakeLists.txt for building the Java API. * Updated CMakeLists.txt again. * Use correct SuppressWarning annotation to silence the compiler * Formatting
85 lines
1.9 KiB
Java
85 lines
1.9 KiB
Java
/**
|
|
Copyright (c) 2012-2014 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
ApplyResult.java
|
|
|
|
Abstract:
|
|
|
|
Author:
|
|
|
|
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
|
|
|
Notes:
|
|
|
|
**/
|
|
|
|
package com.microsoft.z3;
|
|
|
|
import java.lang.ref.ReferenceQueue;
|
|
|
|
/**
|
|
* ApplyResult objects represent the result of an application of a tactic to a
|
|
* goal. It contains the subgoals that were produced.
|
|
**/
|
|
public class ApplyResult extends Z3Object {
|
|
/**
|
|
* The number of Subgoals.
|
|
**/
|
|
public int getNumSubgoals()
|
|
{
|
|
return Native.applyResultGetNumSubgoals(getContext().nCtx(),
|
|
getNativeObject());
|
|
}
|
|
|
|
/**
|
|
* Retrieves the subgoals from the ApplyResult.
|
|
*
|
|
* @throws Z3Exception
|
|
**/
|
|
public Goal[] getSubgoals()
|
|
{
|
|
int n = getNumSubgoals();
|
|
Goal[] res = new Goal[n];
|
|
for (int i = 0; i < n; i++)
|
|
res[i] = new Goal(getContext(),
|
|
Native.applyResultGetSubgoal(getContext().nCtx(), getNativeObject(), i));
|
|
return res;
|
|
}
|
|
|
|
/**
|
|
* A string representation of the ApplyResult.
|
|
**/
|
|
@Override
|
|
public String toString() {
|
|
return Native.applyResultToString(getContext().nCtx(), getNativeObject());
|
|
}
|
|
|
|
ApplyResult(Context ctx, long obj)
|
|
{
|
|
super(ctx, obj);
|
|
}
|
|
|
|
@Override
|
|
void incRef() {
|
|
Native.applyResultIncRef(getContext().nCtx(), getNativeObject());
|
|
}
|
|
|
|
@Override
|
|
void addToReferenceQueue() {
|
|
getContext().getReferenceQueue().storeReference(this, ApplyResultRef::new);
|
|
}
|
|
|
|
private static class ApplyResultRef extends Z3ReferenceQueue.Reference<ApplyResult> {
|
|
|
|
private ApplyResultRef(ApplyResult referent, ReferenceQueue<Z3Object> q) {
|
|
super(referent, q);
|
|
}
|
|
|
|
@Override
|
|
void decRef(Context ctx, long z3Obj) {
|
|
Native.applyResultDecRef(ctx.nCtx(), z3Obj);
|
|
}
|
|
}
|
|
}
|