". Expression: " + ExpressionDumper.dump(functionExpr));}
final Item item0 = funcSeq.itemAt(0);
if (!Type.subTypeOf(item0.getType(), Type.FUNCTION_REFERENCE))
{throw new XPathException(this, ErrorCodes.XPTY0004,
"Type error: expected function, got " + Type.getTypeName(item0.getType()));}
final FunctionReference ref = (FunctionReference)item0;
// if the call is a partial application, create a new function
if (isPartial) {
try {
final FunctionCall call = ref.getCall();
call.setArguments(arguments);
final PartialFunctionApplication partialApp = new PartialFunctionApplication(context, call);
partialApp.analyze(new AnalyzeContextInfo(cachedContextInfo));
return partialApp.eval(contextSequence, contextItem);
} catch (final XPathException e) {
e.setLocation(line, column, getSource());
throw e;
}
} else {
ref.setArguments(arguments);
// need to create a new AnalyzeContextInfo to avoid memory leak
// cachedContextInfo will stay in memory
ref.analyze(new AnalyzeContextInfo(cachedContextInfo));
// Evaluate the function
final Sequence result = ref.eval(contextSequence);
ref.resetState(false);
return result;
}
}