public Expression bind(int nameCode, String uri, String local, Expression[] arguments) throws XPathException {
int fp = getNamePool().allocate("", uri, local);
Long keyObj = new Long(((long)arguments.length)<<32 + (long)fp);
XQueryFunction fd = (XQueryFunction)functions.get(keyObj);
if (fd != null) {
UserFunctionCall ufc = new UserFunctionCall();
ufc.setFunctionNameCode(nameCode);
ufc.setArguments(arguments);
ufc.setStaticType(fd.getResultType());
UserFunction fn = fd.getUserFunction();
if (fn == null) {
// not yet compiled
fd.registerReference(ufc);
} else {
ufc.setFunction(fn, fd.getStaticContext());
}
return ufc;
} else if (allowForwardsReferences) {
UserFunctionCall ufc = new UserFunctionCall();
ufc.setFunctionNameCode(nameCode);
ufc.setArguments(arguments);
unboundFunctionCalls.add(ufc);
return ufc;
} else {
return null;
}