3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-09 15:43:25 +00:00

Added braces

Lack of braces on multi-line statements is considered very scary in
Java.
This commit is contained in:
George Karpenkov 2016-01-06 11:14:53 +01:00
parent ccd88a63a5
commit c435bc379b
8 changed files with 84 additions and 68 deletions

View file

@ -53,15 +53,10 @@ public class AST extends Z3Object implements Comparable<AST>
@Override
public int compareTo(AST other)
{
if (other == null)
if (other == null) {
return 1;
if (getId() < other.getId())
return -1;
else if (getId() > other.getId())
return +1;
else
return 0;
}
return Integer.compare(getId(), other.getId());
}
/**
@ -94,12 +89,13 @@ public class AST extends Z3Object implements Comparable<AST>
public AST translate(Context ctx)
{
if (getContext() == ctx)
if (getContext() == ctx) {
return this;
else
} else {
return new AST(ctx, Native.translate(getContext().nCtx(),
getNativeObject(), ctx.nCtx()));
}
}
/**
* The kind of the AST.

View file

@ -110,8 +110,9 @@ public class Context extends IDisposable
**/
public BoolSort getBoolSort()
{
if (m_boolSort == null)
if (m_boolSort == null) {
m_boolSort = new BoolSort(this);
}
return m_boolSort;
}
@ -120,8 +121,9 @@ public class Context extends IDisposable
**/
public IntSort getIntSort()
{
if (m_intSort == null)
if (m_intSort == null) {
m_intSort = new IntSort(this);
}
return m_intSort;
}
@ -130,8 +132,9 @@ public class Context extends IDisposable
**/
public RealSort getRealSort()
{
if (m_realSort == null)
if (m_realSort == null) {
m_realSort = new RealSort(this);
}
return m_realSort;
}
@ -148,8 +151,9 @@ public class Context extends IDisposable
**/
public SeqSort getStringSort()
{
if (m_stringSort == null)
if (m_stringSort == null) {
m_stringSort = mkStringSort();
}
return m_stringSort;
}

View file

@ -53,15 +53,17 @@ public class Expr extends AST
public Expr simplify(Params p)
{
if (p == null)
if (p == null) {
return Expr.create(getContext(),
Native.simplify(getContext().nCtx(), getNativeObject()));
else
}
else {
return Expr.create(
getContext(),
Native.simplifyEx(getContext().nCtx(), getNativeObject(),
p.getNativeObject()));
}
}
/**
* The function declaration of the function that is applied in this
@ -106,9 +108,10 @@ public class Expr extends AST
{
int n = getNumArgs();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
for (int i = 0; i < n; i++) {
res[i] = Expr.create(getContext(),
Native.getAppArg(getContext().nCtx(), getNativeObject(), i));
}
return res;
}
@ -122,10 +125,11 @@ public class Expr extends AST
public void update(Expr[] args)
{
getContext().checkContextMatch(args);
if (isApp() && args.length != getNumArgs())
if (isApp() && args.length != getNumArgs()) {
throw new Z3Exception("Number of arguments does not match");
}
setNativeObject(Native.updateTerm(getContext().nCtx(), getNativeObject(),
(int) args.length, Expr.arrayToNative(args)));
args.length, Expr.arrayToNative(args)));
}
/**
@ -144,10 +148,11 @@ public class Expr extends AST
{
getContext().checkContextMatch(from);
getContext().checkContextMatch(to);
if (from.length != to.length)
if (from.length != to.length) {
throw new Z3Exception("Argument sizes do not match");
}
return Expr.create(getContext(), Native.substitute(getContext().nCtx(),
getNativeObject(), (int) from.length, Expr.arrayToNative(from),
getNativeObject(), from.length, Expr.arrayToNative(from),
Expr.arrayToNative(to)));
}
@ -160,7 +165,6 @@ public class Expr extends AST
**/
public Expr substitute(Expr from, Expr to)
{
return substitute(new Expr[] { from }, new Expr[] { to });
}
@ -179,7 +183,7 @@ public class Expr extends AST
getContext().checkContextMatch(to);
return Expr.create(getContext(), Native.substituteVars(getContext().nCtx(),
getNativeObject(), (int) to.length, Expr.arrayToNative(to)));
getNativeObject(), to.length, Expr.arrayToNative(to)));
}
/**
@ -193,15 +197,15 @@ public class Expr extends AST
**/
public Expr translate(Context ctx)
{
if (getContext() == ctx)
if (getContext() == ctx) {
return this;
else
} else {
return Expr.create(
ctx,
Native.translate(getContext().nCtx(), getNativeObject(),
ctx.nCtx()));
}
}
/**
* Returns a string representation of the expression.
@ -2123,8 +2127,9 @@ public class Expr extends AST
{
if (!Native.isApp(getContext().nCtx(), obj) &&
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() &&
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt())
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) {
throw new Z3Exception("Underlying object is not a term");
}
super.checkNativeObject(obj);
}

View file

@ -36,8 +36,9 @@ public class FiniteDomainNum extends FiniteDomainExpr
public int getInt()
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
if (!Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res)) {
throw new Z3Exception("Numeral is not an int");
}
return res.value;
}
@ -47,8 +48,9 @@ public class FiniteDomainNum extends FiniteDomainExpr
public long getInt64()
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
if (!Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res)) {
throw new Z3Exception("Numeral is not an int64");
}
return res.value;
}

View file

@ -57,11 +57,12 @@ public final class Global
public static String getParameter(String id)
{
Native.StringPtr res = new Native.StringPtr();
if (!Native.globalParamGet(id, res))
if (!Native.globalParamGet(id, res)) {
return null;
else
} else {
return res.value;
}
}
/**
* Restore the value of all global (and module) parameters.

View file

@ -184,11 +184,12 @@ public class Optimize extends Z3Object
public Model getModel()
{
long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject());
if (x == 0)
if (x == 0) {
return null;
else
} else {
return new Model(getContext(), x);
}
}
/**
* Declare an arithmetical maximization objective.

View file

@ -201,13 +201,14 @@ public class Solver extends Z3Object
public Status check(Expr... assumptions)
{
Z3_lbool r;
if (assumptions == null)
if (assumptions == null) {
r = Z3_lbool.fromInt(Native.solverCheck(getContext().nCtx(),
getNativeObject()));
else
} else {
r = Z3_lbool.fromInt(Native.solverCheckAssumptions(getContext()
.nCtx(), getNativeObject(), (int) assumptions.length, AST
.nCtx(), getNativeObject(), assumptions.length, AST
.arrayToNative(assumptions)));
}
switch (r)
{
case Z3_L_TRUE:
@ -243,11 +244,12 @@ public class Solver extends Z3Object
public Model getModel()
{
long x = Native.solverGetModel(getContext().nCtx(), getNativeObject());
if (x == 0)
if (x == 0) {
return null;
else
} else {
return new Model(getContext(), x);
}
}
/**
* The proof of the last {@code Check}.
@ -261,11 +263,12 @@ public class Solver extends Z3Object
public Expr getProof()
{
long x = Native.solverGetProof(getContext().nCtx(), getNativeObject());
if (x == 0)
if (x == 0) {
return null;
else
} else {
return Expr.create(getContext(), x);
}
}
/**
* The unsat core of the last {@code Check}.

View file

@ -72,13 +72,14 @@ public class Statistics extends Z3Object
**/
public String getValueString()
{
if (isUInt())
if (isUInt()) {
return Integer.toString(m_int);
else if (isDouble())
} else if (isDouble()) {
return Double.toString(m_double);
else
} else {
throw new Z3Exception("Unknown statistical entry type");
}
}
/**
* The string representation of the Entry.
@ -150,14 +151,15 @@ public class Statistics extends Z3Object
{
Entry e;
String k = Native.statsGetKey(getContext().nCtx(), getNativeObject(), i);
if (Native.statsIsUint(getContext().nCtx(), getNativeObject(), i))
if (Native.statsIsUint(getContext().nCtx(), getNativeObject(), i)) {
e = new Entry(k, Native.statsGetUintValue(getContext().nCtx(),
getNativeObject(), i));
else if (Native.statsIsDouble(getContext().nCtx(), getNativeObject(), i))
} else if (Native.statsIsDouble(getContext().nCtx(), getNativeObject(), i)) {
e = new Entry(k, Native.statsGetDoubleValue(getContext().nCtx(),
getNativeObject(), i));
else
} else {
throw new Z3Exception("Unknown data entry value");
}
res[i] = e;
}
return res;
@ -186,9 +188,11 @@ public class Statistics extends Z3Object
{
int n = size();
Entry[] es = getEntries();
for (int i = 0; i < n; i++)
if (es[i].Key == key)
for (int i = 0; i < n; i++) {
if (es[i].Key.equals(key)) {
return es[i];
}
}
return null;
}