3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 20:18:18 +00:00
z3/src/api/java/ApplyResult.java
George Karpenkov 22ffd65d1e Java API: split incRef into incRef and addToReferenceQueue
One method should do one thing only, it's easy to mix things up
otherwise.
2016-06-12 21:01:58 +02:00

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;
/**
* 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;
}
/**
* Convert a model for the subgoal {@code i} into a model for the
* original goal {@code g}, that the ApplyResult was obtained from.
*
* @return A model for {@code g}
* @throws Z3Exception
**/
public Model convertModel(int i, Model m)
{
return new Model(getContext(),
Native.applyResultConvertModel(getContext().nCtx(), getNativeObject(), i, m.getNativeObject()));
}
/**
* 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().getApplyResultDRQ().storeReference(getContext(), this);
}
}