Expression[] actions = new Expression[entries];
int w = 0;
AxisIterator kids = iterateAxis(Axis.CHILD);
while(true) {
NodeInfo curr = (NodeInfo)kids.next();
if (curr == null) {
break;
}
if (curr instanceof XSLWhen) {
conditions[w] = ((XSLWhen)curr).getCondition();
Block b = new Block();
b.setLocationId(allocateLocationId(getSystemId(), curr.getLineNumber()));
((XSLWhen)curr).compileChildren(exec, b, true);
try {
actions[w] = b.simplify(((XSLWhen)curr).getStaticContext());
} catch (XPathException e) {
compileError(e);
}
if (getConfiguration().getTraceListener() != null) {
TraceWrapper trace = makeTraceInstruction((XSLWhen)curr, actions[w]);
trace.setParentExpression(b);
actions[w] = trace;
}
// Optimize for constant conditions (true or false)
if (conditions[w] instanceof BooleanValue) {
if (((BooleanValue)conditions[w]).getBooleanValue()) {
// constant true: truncate the tests here
entries = w+1;
break;
} else {
// constant false: omit this test
w--;
entries--;
}
}
w++;
} else if (curr instanceof XSLOtherwise) {
conditions[w] = BooleanValue.TRUE;
Block b = new Block();
b.setLocationId(allocateLocationId(getSystemId(), curr.getLineNumber()));
((XSLOtherwise)curr).compileChildren(exec, b, true);
try {
actions[w] = b.simplify(((XSLOtherwise)curr).getStaticContext());
} catch (XPathException e) {
compileError(e);