net.sf.saxon.instruct
public final class UserFunction extends Procedure implements InstructionInfoProvider
It is assumed that type-checking, of both the arguments and the results, has been handled at compile time. That is, the expression supplied as the body of the function must be wrapped in code to check or convert the result to the required type, and calls on the function must be wrapped at compile time to check or convert the supplied arguments.
Constructor Summary | |
---|---|
UserFunction() | |
UserFunction(Expression body) |
Method Summary | |
---|---|
ValueRepresentation | call(ValueRepresentation[] actualArgs, XPathContextMajor context, boolean evaluateTailCalls)
Call this function. |
ValueRepresentation | call(ValueRepresentation[] actualArgs, Controller controller)
Call this function. |
SequenceType | getArgumentType(int n)
Get the required types of an argument to this function |
int | getFunctionNameCode()
Get the namepool name code of the function |
InstructionInfo | getInstructionInfo()
Get the InstructionInfo details about the construct. |
int | getNumberOfArguments()
Get the arity of this function |
UserFunctionParameter[] | getParameterDefinitions() |
SequenceType | getResultType()
Get the type of value returned by this function |
boolean | isTailRecursive() |
void | setFunctionNameCode(int nameCode)
Set the namepool name code of the function |
void | setMemoFunction(boolean isMemo)
Mark this function as a memo function (or not) |
void | setParameterDefinitions(UserFunctionParameter[] params) |
void | setResultType(SequenceType resultType) |
void | setTailRecursive(boolean tailCalls) |
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. context This provides the run-time context for evaluating the function. It is the caller's responsibility to allocate a "clean" context for the function to use; the context that is provided will be overwritten by the function. evaluateTailCalls if true, then any function calls contained in the body of the function are evaluated in the normal way, whether or not they are marked as tail calls. If the argument is false, then tail calls are not evaluated, and instead a FunctionCallPackage is returned containing the information needed to evaluate the function. The caller must then be prepared to deal with this returned value by evaluating the packaged function call (which may return further packaged function calls, and so on).
Returns: a Value representing the result of the function.
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. controller This provides the run-time context for evaluating the function. A Controller may be obtained by calling XQueryExpression. This may be used for a series of calls on functions defined in the same module as the XQueryExpression.
Returns: a Value representing the result of the function.
Parameters: n identifies the argument in question, starting at 0
Returns: a SequenceType object, indicating the required type of the argument
Returns: a name code representing the function name
Returns: the number of arguments
Returns: the declared result type, or the inferred result type if this is more precise
Parameters: nameCode represents the function name
Parameters: isMemo true if this is a memo function