Class UserFunctionCall
- All Implemented Interfaces:
ComponentInvocation
,ContextOriginator
,ExportAgent
,Locatable
,UserFunctionResolvable
,IdentityComparable
,Traceable
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.expr.FunctionCall
FunctionCall.FunctionCallElaborator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a function call to a user-written function in a query or stylesheetCreate an unbound function call (typically, a forwards reference in XQuery) -
Method Summary
Modifier and TypeMethodDescriptionaddToPathMap
(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.void
protected int
Determine the cardinality of the resultprotected int
Compute the special properties of this expression.copy
(RebindingMap rebindings) Copy an expression.void
copyFrom
(UserFunctionCall ufc2) Copy details from another user function callSequence[]
evaluateArguments
(XPathContext c, boolean streamed) Call the function, returning the value as an item.void
Diagnostic print of expression structure.int
Get the binding slot to be used.Make an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.Get the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original.Get the function that is being called by this function call.final StructuredQName
Get the qualified of the function being calledint
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().int
Determine 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 possibleGet 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) getStaticUType
(UType contextItemType) Get the static type of the expression as a UType, following precisely the type inference rules defined in the XSLT 3.0 specification.Get the symbolic name of the component that this invocation referencesgetTargetComponent
(XPathContext context) getTargetFunction
(XPathContext context) Get the target function to be calledboolean
boolean
boolean
Determine whether this is a tail call (not necessarily a recursive tail call)boolean
Determine whether this is an updating expression as defined in the XQuery update specificationCall the function, returning an iterator over the results.int
markTailFunctionCalls
(StructuredQName qName, int arity) Mark tail-recursive calls on stylesheet functions.optimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Perform optimisation of an expression and its subexpressions.preEvaluate
(ExpressionVisitor visitor) Pre-evaluate a function at compile time.void
process
(Outputter output, XPathContext context) Process the function call in push modevoid
Reset the static properties of the expression to -1, so that they have to be recomputed next time they are used.void
setBeingInlined
(boolean beingInlined) void
setBindingSlot
(int slot) Set the binding slot to be used.void
setFunction
(UserFunction compiledFunction) Create the reference to the function to be calledfinal void
Set the name of the function being calledvoid
setStaticType
(SequenceType type) Set the static typetypeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Type-check the expression.Methods inherited from class net.sf.saxon.expr.FunctionCall
addExternalFunctionCallToPathMap, adjustRequiredType, checkArgumentCount, checkArguments, checkFunctionCall, computeHashCode, equals, getArg, getArguments, getArity, getDisplayName, getNetCost, getOperanda, operands, plural, preEvaluateIfConstant, setArg, setArguments, setOperanda, setOperanda, simplifyArguments, toShortString, toString
Methods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, evaluateAsString, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getPackageData, getParentExpression, getProperties, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isVacuousExpression, makeElaborator, operandList, operandSparseList, optimizeChildren, prepareForStreaming, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
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 -
UserFunctionCall
Create an unbound function call (typically, a forwards reference in XQuery)
-
-
Method Details
-
isBeingInlined
public boolean isBeingInlined() -
setBeingInlined
public void setBeingInlined(boolean beingInlined) -
copyFrom
Copy details from another user function call -
setFunctionName
Set the name of the function being called- Parameters:
name
- the name of the function
-
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- Specified by:
setFunction
in interfaceUserFunctionResolvable
- Parameters:
compiledFunction
- the function being called
-
setBindingSlot
public void setBindingSlot(int slot) Set the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target template is to be found. The target function is not held directly in the UserFunctionCall expression itself because it can be overridden in a using package.- Specified by:
setBindingSlot
in interfaceComponentInvocation
- Parameters:
slot
- the offset in the binding vector of the containing package where the target template can be found.
-
getBindingSlot
public int getBindingSlot()Get the binding slot to be used. This is the offset within the binding vector of the containing component where the actual target template is to be found.- Specified by:
getBindingSlot
in interfaceComponentInvocation
- Returns:
- the offset in the binding vector of the containing package where the target template can be found.
-
getFunction
Get the function that is being called by this function call. This is the provisional binding: the actual function might be an override of this one.- Returns:
- the function being called
-
getFixedTarget
Description copied from interface:ComponentInvocation
Get the target component if this is known in advance, that is, if the target component is private or final, or in some other cases such as xsl:original. Otherwise, return null.- Specified by:
getFixedTarget
in interfaceComponentInvocation
- Returns:
- the bound component if the binding has been fixed
-
getUnboundCallDetails
-
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() -
getFunctionName
Get the qualified of the function being called- Specified by:
getFunctionName
in classFunctionCall
- Returns:
- the qualified name
-
getSymbolicName
Description copied from interface:ComponentInvocation
Get the symbolic name of the component that this invocation references- Specified by:
getSymbolicName
in interfaceComponentInvocation
- Returns:
- the symbolic name of the target component, or null if there is no component referenced
-
getTarget
-
allocateArgumentEvaluators
public void allocateArgumentEvaluators() -
getArgumentEvaluators
-
preEvaluate
Pre-evaluate a function at compile time. This version of the method suppresses early evaluation by doing nothing.- Overrides:
preEvaluate
in 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:
getItemType
in classExpression
- Returns:
- Type.ITEM (meaning not known in advance)
-
getStaticUType
Get the static type of the expression as a UType, following precisely the type inference rules defined in the XSLT 3.0 specification.- Overrides:
getStaticUType
in classExpression
- Parameters:
contextItemType
- the static type of the context item- Returns:
- the static item type of the expression according to the XSLT 3.0 defined rules
-
getIntrinsicDependencies
public int getIntrinsicDependencies()Description copied from class:Expression
Determine 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:
getIntrinsicDependencies
in classExpression
- Returns:
- an integer containing 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:
isUpdatingExpression
in 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:
computeSpecialProperties
in classExpression
- Returns:
- the special properties, as a bit-significant integer
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variable bindings that need to be changed- Returns:
- the copy of the original expression
-
computeCardinality
protected int computeCardinality()Determine the cardinality of the result- Specified by:
computeCardinality
in 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
. May also returnStaticProperty.ALLOWS_ZERO
if the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANY
if if is known to return a sequence of length two or more.
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Description copied from class:FunctionCall
Type-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:
typeCheck
in classFunctionCall
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- 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, ContextItemStaticInfo contextItemType) throws XPathException Description copied from class:FunctionCall
Perform 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:
optimize
in 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)
-
resetLocalStaticProperties
public void resetLocalStaticProperties()Reset the static properties of the expression to -1, so that they have to be recomputed next time they are used.- Overrides:
resetLocalStaticProperties
in classExpression
-
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:
addToPathMap
in 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:
markTailFunctionCalls
in classExpression
- Parameters:
qName
- the name of the functionarity
- the arity (number of parameters) of the function- Returns:
NOT_TAIL_CALL
if no tail call was found;FOREIGN_TAIL_CALL
if a tail call on a different function was found;SELF_TAIL_CALL
if a tail recursive call was found and if this call accounts for the whole of the value.
-
getImplementationMethod
public int getImplementationMethod()Description copied from class:FunctionCall
An 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:
getImplementationMethod
in classFunctionCall
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.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:
evaluateItem
in classFunctionCall
- 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:
iterate
in classFunctionCall
- 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
-
process
Process the function call in push mode- Overrides:
process
in classExpression
- Parameters:
output
- the destination for the resultcontext
- the XPath dynamic context- Throws:
XPathException
- if a dynamic error occurs
-
getTargetComponent
-
getTargetFunction
Description copied from class:FunctionCall
Get the target function to be called- Specified by:
getTargetFunction
in classFunctionCall
- Parameters:
context
- the dynamic evaluation context- Returns:
- the target function
-
evaluateArguments
- Throws:
XPathException
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Overrides:
export
in classFunctionCall
- Parameters:
out
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
getExpressionName
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classFunctionCall
- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
-
getProperty
- Overrides:
getProperty
in classExpression
-
getObjectName
Description copied from interface:Traceable
Get 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:
getObjectName
in interfaceTraceable
- Overrides:
getObjectName
in classExpression
- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
getElaborator
Description copied from class:Expression
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- an appropriate
Elaborator
-