Class UserFunctionCall
- All Implemented Interfaces:
Serializable, SourceLocator, LocationProvider, SaxonLocator, InstructionInfo, Locator
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from class FunctionCall
argument -
Constructor Summary
ConstructorsConstructorDescriptionCreate a function call to a user-written function in a query or stylesheet -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.voidcheckArguments(ExpressionVisitor visitor) Method called during the type checking phasevoidcheckFunctionCall(UserFunction compiledFunction, ExpressionVisitor visitor) Check the function call against the declared function signaturevoidCompute the evaluation mode of each argumentintDetermine the cardinality of the resultprotected intCompute the special properties of this expression.copy()Copy an expression.dynamicCall(ValueRepresentation[] suppliedArguments, XPathContext context) Call the function dynamically.Call the function, returning the value as an item.voidevaluatePendingUpdates(XPathContext context, PendingUpdateList pul) Evaluate an updating expression, adding the results to a Pending Update List.voidDiagnostic print of expression structure.int[]Get the evaluation modes that have been determined for each of the argumentsintGet the type of this expression for use in tracing and diagnosticsGet the function that is being called by this function callfinal StructuredQNameGet the qualified of the function being calledintAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intDetermine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.Determine the data type of the expression, if possibleintgetLineNumber(long locationId) Get the line number within the document or module containing a particular locationGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.getProperty(String name) Get the value of a particular property of the instruction.getSystemId(long locationId) Get the URI of the document or module containing a particular locationbooleanbooleanDetermine whether this is a tail call (not necessarily a recursive tail call)booleanDetermine whether this is an updating expression as defined in the XQuery update specificationCall the function, returning an iterator over the results.iterateEvents(XPathContext context) Process the function call in pull modeintmarkTailFunctionCalls(StructuredQName qName, int arity) Mark tail-recursive calls on stylesheet functions.optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) Perform optimisation of an expression and its subexpressions.preEvaluate(ExpressionVisitor visitor) Pre-evaluate a function at compile time.voidprocess(XPathContext context) Process the function call in push modepromote(PromotionOffer offer, Expression parent) Promote this expression if possiblebooleanreplaceSubExpression(Expression original, Expression replacement) Replace one subexpression by a replacement subexpressionvoidsetFunction(UserFunction compiledFunction) Create the reference to the function to be calledvoidsetStaticType(SequenceType type) Set the static typetypeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) Type-check the expression.Methods inherited from class FunctionCall
addExternalFunctionCallToPathMap, checkArgumentCount, equals, getArguments, getDisplayName, getExpressionName, getNumberOfArguments, hashCode, iterateSubExpressions, setArguments, setFunctionName, simplify, simplifyArguments, toStringMethods inherited from class Expression
adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, explain, getCardinality, getColumnNumber, getColumnNumber, getContainer, getDependencies, getEvaluationMethod, getExecutable, getHostLanguage, getIntegerBounds, getLineNumber, getLocationId, getLocationProvider, getProperties, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isVacuousExpression, iterateSameFocusSubExpressions, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError
-
Field Details
-
NOT_TAIL_CALL
public static final int NOT_TAIL_CALL- See Also:
-
FOREIGN_TAIL_CALL
public static final int FOREIGN_TAIL_CALL- See Also:
-
SELF_TAIL_CALL
public static final int SELF_TAIL_CALL- See Also:
-
-
Constructor Details
-
UserFunctionCall
public UserFunctionCall()Create a function call to a user-written function in a query or stylesheet
-
-
Method Details
-
setStaticType
Set the static type- Parameters:
type- the static type of the result of the function call
-
setFunction
Create the reference to the function to be called- Parameters:
compiledFunction- the function being called
-
checkFunctionCall
public void checkFunctionCall(UserFunction compiledFunction, ExpressionVisitor visitor) throws XPathException Check the function call against the declared function signature- Parameters:
compiledFunction- the function being calledvisitor- an expression visitor- Throws:
XPathException
-
getFunction
Get the function that is being called by this function call- Returns:
- the function being called
-
isTailCall
public boolean isTailCall()Determine whether this is a tail call (not necessarily a recursive tail call)- Returns:
- true if this function call is a tail call
-
isRecursiveTailCall
public boolean isRecursiveTailCall() -
checkArguments
Method called during the type checking phase- Specified by:
checkArgumentsin classFunctionCall- Parameters:
visitor- the expression visitor- Throws:
XPathException- if the arguments are incorrect
-
getFunctionName
Get the qualified of the function being called- Overrides:
getFunctionNamein classFunctionCall- Returns:
- the qualified name
-
getArgumentEvaluationModes
public int[] getArgumentEvaluationModes()Get the evaluation modes that have been determined for each of the arguments- Returns:
- an array of integers representing the evaluation modes, one for each argument
-
preEvaluate
Pre-evaluate a function at compile time. This version of the method suppresses early evaluation by doing nothing.- Overrides:
preEvaluatein classFunctionCall- Parameters:
visitor- an expression visitor- Returns:
- the result of the early evaluation, or the original expression, or potentially a simplified expression
-
getItemType
Determine the data type of the expression, if possible- Specified by:
getItemTypein classExpression- Parameters:
th- the type hierarchy cache- Returns:
- Type.ITEM (meaning not known in advance)
-
getIntrinsicDependencies
public int getIntrinsicDependencies()Description copied from class:ExpressionDetermine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".- Overrides:
getIntrinsicDependenciesin classExpression- Returns:
- a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
isUpdatingExpression
public boolean isUpdatingExpression()Determine whether this is an updating expression as defined in the XQuery update specification- Overrides:
isUpdatingExpressionin classExpression- Returns:
- true if this is an updating expression
-
computeSpecialProperties
protected int computeSpecialProperties()Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in classStaticProperty. The "special" properties are properties other than cardinality and dependencies, and most of them relate to properties of node sequences, for example whether the nodes are in document order.- Overrides:
computeSpecialPropertiesin classExpression- Returns:
- the special properties, as a bit-significant integer
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Returns:
- the copy of the original expression
-
computeCardinality
public int computeCardinality()Determine the cardinality of the result- Specified by:
computeCardinalityin classExpression- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE,StaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE,StaticProperty.ALLOWS_ZERO_OR_MORE
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException Description copied from class:FunctionCallType-check the expression. This also calls preEvaluate() to evaluate the function if all the arguments are constant; functions that do not require this behavior can override the preEvaluate method.- Overrides:
typeCheckin classFunctionCall- Parameters:
visitor- an expression visitorcontextItemType- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
optimize
public Expression optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException Description copied from class:FunctionCallPerform optimisation of an expression and its subexpressions.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
- Overrides:
optimizein classFunctionCall- Parameters:
visitor- an expression visitorcontextItemType- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
promote
Promote this expression if possible- Overrides:
promotein classFunctionCall- Parameters:
offer- details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expressionparent- the containing expression in the expression tree- Returns:
- if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression
- Throws:
XPathException- if any error is detected
-
computeArgumentEvaluationModes
public void computeArgumentEvaluationModes()Compute the evaluation mode of each argument -
replaceSubExpression
Description copied from class:FunctionCallReplace one subexpression by a replacement subexpression- Overrides:
replaceSubExpressionin classFunctionCall- Parameters:
original- the original subexpressionreplacement- the replacement subexpression- Returns:
- true if the original subexpression is found
-
addToPathMap
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
- Overrides:
addToPathMapin classExpression- Parameters:
pathMap- the PathMap to which the expression should be addedpathMapNodeSet- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.
-
markTailFunctionCalls
Mark tail-recursive calls on stylesheet functions. This marks the function call as tailRecursive if if is a call to the containing function, and in this case it also returns "true" to the caller to indicate that a tail call was found.- Overrides:
markTailFunctionCallsin classExpression- Parameters:
qName- the name of the functionarity- the arity (number of parameters) of the function- Returns:
NOT_TAIL_CALLif no tail call was found;FOREIGN_TAIL_CALLif a tail call on a different function was found;
-
getImplementationMethod
public int getImplementationMethod()Description copied from class:ExpressionAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.- Overrides:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
evaluateItem
Call the function, returning the value as an item. This method will be used only when the cardinality is zero or one. If the function is tail recursive, it returns an Object representing the arguments to the next (recursive) call- Overrides:
evaluateItemin classExpression- Parameters:
c- The context in which the expression is to be evaluated- Returns:
- the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
iterate
Call the function, returning an iterator over the results. (But if the function is tail recursive, it returns an iterator over the arguments of the recursive call)- Overrides:
iteratein classExpression- Parameters:
c- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
evaluatePendingUpdates
public void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException Evaluate an updating expression, adding the results to a Pending Update List. The default implementation of this method, which is used for non-updating expressions, throws an UnsupportedOperationException- Overrides:
evaluatePendingUpdatesin classExpression- Parameters:
context- the XPath dynamic evaluation contextpul- the pending update list to which the results should be written- Throws:
XPathException- if evaluation fails
-
process
Process the function call in push mode- Overrides:
processin classExpression- Parameters:
context- the XPath dynamic context- Throws:
XPathException
-
iterateEvents
Process the function call in pull mode- Overrides:
iterateEventsin classExpression- Parameters:
context- the XPath dynamic context- Returns:
- the result of the expression as an iterator over a sequence of PullEvent objects
- Throws:
XPathException
-
evaluateArguments
- Throws:
XPathException
-
dynamicCall
public ValueRepresentation dynamicCall(ValueRepresentation[] suppliedArguments, XPathContext context) throws XPathException Call the function dynamically. For this to be possible, the static arguments of the function call must have been set up asSuppliedParameterReferenceobjects. The actual arguments are placed on the callee's stack, and the type conversion takes place "in situ".- Parameters:
suppliedArguments- the values to be used for the arguments of the functioncontext- the dynamic evaluation context- Returns:
- the result of evaluating the function
- Throws:
XPathException
-
explain
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Overrides:
explainin classFunctionCall- Parameters:
out- the expression presenter used to display the structure
-
getConstructType
public int getConstructType()Description copied from class:ExpressionGet the type of this expression for use in tracing and diagnostics- Specified by:
getConstructTypein interfaceInstructionInfo- Overrides:
getConstructTypein classExpression- Returns:
- the type of expression, as enumerated in class
Location
-
getProperty
Description copied from interface:InstructionInfoGet the value of a particular property of the instruction. Properties of XSLT instructions are generally known by the name of the stylesheet attribute that defines them.- Specified by:
getPropertyin interfaceInstructionInfo- Overrides:
getPropertyin classExpression- Parameters:
name- The name of the required property- Returns:
- The value of the requested property, or null if the property is not available
-
getObjectName
Description copied from interface:InstructionInfoGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.- Specified by:
getObjectNamein interfaceInstructionInfo- Overrides:
getObjectNamein classExpression- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
getLineNumber
public int getLineNumber(long locationId) Get the line number within the document or module containing a particular location- Specified by:
getLineNumberin interfaceLocationProvider- Overrides:
getLineNumberin classExpression- Parameters:
locationId- identifier of the location in question (as passed down the Receiver pipeline)- Returns:
- the line number within the document or module.
-
getSystemId
Get the URI of the document or module containing a particular location- Specified by:
getSystemIdin interfaceLocationProvider- Overrides:
getSystemIdin classExpression- Parameters:
locationId- identifier of the location in question (as passed down the Receiver pipeline)- Returns:
- the URI of the document or module.
-