final int refcnt = ((BindingVariable) referent).getReferenceCount();
if(refcnt == 1) {
final int csize = flwr.getClauses().size();
if(csize > 0) {
final Binding clause = flwr.getClauses().get(0);
final BindingVariable bindingVar = clause.getVariable();
if(bindingVar == referent) {
final XQExpression bindingExpr = bindingVar.getValue();
pathExpr.setStep(0, bindingExpr);
return pathExpr;
}
}
}
}
}
} else if(retExpr instanceof VarRef) {
final Variable referent = ((VarRef) retExpr).getValue();
if(referent instanceof BindingVariable) {
final int refcnt = ((BindingVariable) referent).getReferenceCount();
if(refcnt == 1) {
for(Binding clause : flwr.getClauses()) {
final BindingVariable bindingVar = clause.getVariable();
if(bindingVar == referent) {
XQExpression bindingExpr = bindingVar.getValue();
Type type = bindingVar.getType();
if(type != Untyped.UNTYPED) {
return new TypePromotedExpr(bindingExpr, type);
} else {
return bindingExpr;
}