}
}
isLoopInvariant &= b.isLoopInvariant();
}
// #2 return
XQExpression filteredRet = flwr.getFilteredReturnExpr();
if(filteredRet != null) {
XQExpression filteredRet2 = filteredRet.visit(this, ctxt);
flwr.setFilteredReturnExpr(filteredRet2);
isLoopInvariant &= filteredRet2.isLoopInvariant();
} else {
// #2-1 where filtering
XQExpression where = flwr.getWhereExpr();
if(where != null) {
where.visit(this, ctxt);
isLoopInvariant &= where.isLoopInvariant();
}
// #2-2 return
XQExpression ret = flwr.getReturnExpr();
assert (ret != null);
ret.visit(this, ctxt);
isLoopInvariant &= ret.isLoopInvariant();
}
// #3 order by sorting
for(OrderSpec o : flwr.getOrderSpecs()) {
o.visit(this, ctxt);
isLoopInvariant &= o.isLoopInvariant();
}
if(isLoopInvariant) {
for(Binding b : bindings) {
removeInvariants(b);
}
if(filteredRet != null) {
removeInvariants(filteredRet);
} else {
XQExpression where = flwr.getWhereExpr();
if(where != null) {
removeInvariants(where);
}
XQExpression ret = flwr.getReturnExpr();
removeInvariants(ret);
}
for(OrderSpec o : flwr.getOrderSpecs()) {
removeInvariants(o);
}