}
private int readBoolean (String disName, int index, String indent,
String name, UnionEntry u, PrintWriter stream)
{
UnionBranch firstBranch = (UnionBranch)u.branches ().firstElement ();
UnionBranch secondBranch;
if (u.branches ().size () == 2)
secondBranch = (UnionBranch)u.branches ().lastElement ();
else
secondBranch = null;
boolean firstBranchIsTrue = false;
boolean noCases = false;
try {
if (u.branches ().size () == 1 &&
(u.defaultBranch () != null || firstBranch.labels.size () == 2)) {
noCases = true;
} else {
Expression expr = (Expression)(firstBranch.labels.firstElement()) ;
Boolean bool = (Boolean)(expr.evaluate()) ;
firstBranchIsTrue = bool.booleanValue ();
}
} catch (EvaluationException ex) {
// no action
}
if (noCases) {
// There is only a default label. Since there are no cases,
// there is no need for if...else branches.
index = readBranch (index, indent, firstBranch.typedef.name (), "", firstBranch.typedef, stream);
} else {
// If first branch is false, swap branches
if (!firstBranchIsTrue) {
UnionBranch tmp = firstBranch;
firstBranch = secondBranch;
secondBranch = tmp;
}
stream.println (indent + "if (" + disName + ')');