}
if (referees.get(i + 1) instanceof GlobalVariable) {
GlobalVariable next = (GlobalVariable)referees.get(i + 1);
message += " uses $" + next.getVariableQName().getDisplayName();
} else if (referees.get(i + 1) instanceof XQueryFunction) {
XQueryFunction next = (XQueryFunction)referees.get(i + 1);
message += " calls " + next.getFunctionName().getDisplayName() +
"#" + next.getNumberOfArguments() + "()";
}
}
message += '.';
XPathException err = new XPathException(message);
err.setErrorCode("XQST0054");
err.setIsStaticError(true);
err.setLocator(this);
throw err;
}
if (select != null) {
referees.push(this);
List list = new ArrayList(10);
ExpressionTool.gatherReferencedVariables(select, list);
for (int i=0; i<list.size(); i++) {
Binding b = (Binding)list.get(i);
if (b instanceof GlobalVariable) {
((GlobalVariable)b).lookForCycles(referees, globalFunctionLibrary);
}
}
list.clear();
ExpressionTool.gatherCalledFunctionNames(select, list);
for (int i=0; i<list.size(); i++) {
XQueryFunction f = globalFunctionLibrary.getDeclarationByKey((String)list.get(i));
if (!referees.contains(f)) {
// recursive function calls are allowed
lookForFunctionCycles(f, referees, globalFunctionLibrary);
}
}