public final class LocalParam extends Instruction implements LocalBinding
The xsl:param element in XSLT has mandatory attribute name and optional attribute select. It can also be specified as required="yes" or required="no".
This is used only for parameters to XSLT templates. For function calls, the caller of the function
places supplied arguments onto the callee's stackframe and the callee does not need to do anything.
Global parameters (XQuery external variables) are handled using GlobalParam
.
The LocalParam class is also used to represent parameters with the saxon:iterate instruction
Changed in Saxon 9.8 to combine the previously-separate LocalParamSetter and LocalParam classes into one
Modifier and Type | Field and Description |
---|---|
protected Evaluator |
evaluator |
protected int |
referenceCount |
protected int |
slotNumber |
protected StructuredQName |
variableQName |
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 and Description |
---|
LocalParam() |
Modifier and Type | Method and Description |
---|---|
void |
addReference(VariableReference ref,
boolean isLoopingReference)
Register a variable reference that refers to the variable bound in this expression
|
void |
checkAgainstRequiredType(ExpressionVisitor visitor)
Check the select expression against the required type.
|
int |
computeCardinality()
Get the cardinality of the sequence returned by evaluating this instruction
|
void |
computeEvaluationMode() |
int |
computeSpecialProperties()
Get the static properties of this expression (other than its type).
|
LocalParam |
copy(RebindingMap rebindings)
Copy an expression.
|
Sequence<?> |
evaluateVariable(XPathContext c)
Evaluate the variable
|
void |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
int |
getCardinality()
Get the cardinality of the result of this instruction.
|
Expression |
getConversion()
Get the conversion expression
|
int |
getConversionEvaluationMode() |
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
int |
getInstructionNameCode()
Get the name of this instruction for diagnostic and tracing purposes
|
IntegerValue[] |
getIntegerBoundsForVariable()
If the variable is bound to an integer, get the minimum and maximum possible values.
|
ItemType |
getItemType()
Get the item type of the items returned by evaluating this instruction
|
int |
getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number.
|
SequenceType |
getRequiredType()
Get the required type of this variable
|
Expression |
getSelectExpression()
Get the expression to which this variable is bound
|
Sequence<?> |
getSelectValue(XPathContext context)
Evaluate the variable.
|
int |
getSlotNumber()
Get the slot number allocated to this variable
|
StructuredQName |
getVariableQName()
Get the name of this variable
|
boolean |
hasVariableBinding(Binding binding)
Ask whether this expression is, or contains, the binding of a given variable
|
boolean |
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign
extension element.
|
boolean |
isCompatible(LocalParam other)
Check if parameter is compatible with another
|
boolean |
isGlobal()
Indicate whether the binding is local or global.
|
boolean |
isImplicitlyRequiredParam()
Ask whether this variable represents a parameter that is implicitly required, because there is no usable
default value
|
boolean |
isIndexedVariable()
Ask whether the binding is to be indexed
|
boolean |
isLiftable(boolean forStreaming)
Ask whether the expression can be lifted out of a loop, assuming it has no dependencies
on the controlling variable/focus of the loop
|
boolean |
isRequiredParam()
Ask whether this variable represents a required parameter
|
boolean |
isTunnelParam()
Ask whether this variable represents a tunnel parameter
|
boolean |
mayCreateNewNodes()
Determine whether this instruction creates new nodes.
|
java.lang.Iterable<Operand> |
operands()
Get all the XPath expressions associated with this instruction
(in XSLT terms, the expression present on attributes of the instruction,
as distinct from the child instructions in a sequence construction)
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.
|
TailCall |
processLeavingTail(XPathContext context)
Process the local parameter declaration
|
void |
setConversion(Expression convertor)
Define a conversion that is to be applied to the supplied parameter value.
|
void |
setImplicitlyRequiredParam(boolean requiredParam)
Indicate that this variable represents a parameter that is implicitly required (because there is no
usable default value)
|
void |
setIndexedVariable()
Say that the bound value has the potential to be indexed
|
void |
setReferenceCount(int refCount)
Set the nominal number of references to this variable
|
void |
setRequiredParam(boolean requiredParam)
Indicate that this variable represents a required parameter
|
void |
setRequiredType(SequenceType required)
Set the required type of this variable
|
void |
setSelectExpression(Expression select)
Set the expression to which this variable is bound
|
void |
setSlotNumber(int s)
Set the slot number of this variable
|
void |
setTunnel(boolean tunnel)
Indicate whether this variable represents a tunnel parameter
|
void |
setVariableQName(StructuredQName s)
Set the name of the variable
|
java.lang.String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform type checking of an expression and its subexpressions.
|
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, dynamicError, evaluateAsString, evaluateItem, getConstructType, getImplementationMethod, getNetCost, getSourceLocator, isInstruction, isXSLT, iterate, process, someOperandCreatesNewNodes
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dynamicError, effectiveBooleanValue, equals, evaluatePendingUpdates, explain, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, hasCompatibleStaticContext, hashCode, hasSpecialProperty, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toString, typeCheckChildren, typeError, unordered, verifyParentPointers
protected StructuredQName variableQName
protected int slotNumber
protected int referenceCount
protected Evaluator evaluator
public void setSelectExpression(Expression select)
select
- the initializing expressionpublic Expression getSelectExpression()
public void setRequiredType(SequenceType required)
required
- the required typepublic SequenceType getRequiredType()
getRequiredType
in interface Binding
public void setRequiredParam(boolean requiredParam)
requiredParam
- true if this is a required parameterpublic void setImplicitlyRequiredParam(boolean requiredParam)
requiredParam
- true if this is an implicitly required parameterpublic void setTunnel(boolean tunnel)
tunnel
- true if this is a tunnel parameterpublic void setReferenceCount(int refCount)
refCount
- the nominal number of referencespublic int getCardinality()
getCardinality
in class Expression
public boolean isAssignable()
Binding
isAssignable
in interface Binding
public boolean isGlobal()
Binding
public int getLocalSlotNumber()
getLocalSlotNumber
in interface LocalBinding
public final boolean isRequiredParam()
public final boolean isImplicitlyRequiredParam()
public final boolean isTunnelParam()
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
Expression
This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
typeCheck
in class Expression
visitor
- an expression visitorcontextItemType
- Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
Expression
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.
optimize
in class Expression
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 to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public void computeEvaluationMode()
public LocalParam copy(RebindingMap rebindings)
copy
in class Expression
rebindings
- a mutable list of (old binding, new binding) pairs
that is used to update the bindings held in any
local variable references that are copied.public void addReference(VariableReference ref, boolean isLoopingReference)
Binding
addReference
in interface Binding
ref
- the variable referenceisLoopingReference
- - true if the reference occurs within a loop, such as the predicate
of a filter expressionpublic void checkAgainstRequiredType(ExpressionVisitor visitor) throws XPathException
visitor
- an expression visitorXPathException
- if the check failspublic Sequence<?> getSelectValue(XPathContext context) throws XPathException
context
- the XPath dynamic contextXPathException
- if evaluation of the select expression fails
with a dynamic errorpublic int getSlotNumber()
public void setSlotNumber(int s)
s
- the slot number, that is, the position allocated to this variable on its stack framepublic void setVariableQName(StructuredQName s)
s
- the name of the variable (a QName)public StructuredQName getVariableQName()
getVariableQName
in interface Binding
public void setConversion(Expression convertor)
convertor
- The expression to be applied. This performs type checking,
and the basic conversions implied by function calling rules, for example
numeric promotion, atomization, and conversion of untyped atomic values to
a required type. The conversion uses the actual parameter value as input,
referencing it using a VariableReference. The argument can be null to indicate
that no conversion is required.public Expression getConversion()
public int getConversionEvaluationMode()
public int getInstructionNameCode()
getInstructionNameCode
in class Instruction
public java.lang.Iterable<Operand> operands()
operands
in class Instruction
public TailCall processLeavingTail(XPathContext context) throws XPathException
processLeavingTail
in interface TailCallReturner
processLeavingTail
in class Instruction
context
- the dynamic contextXPathException
- if a dynamic error occurs in the evaluationpublic IntegerValue[] getIntegerBoundsForVariable()
getIntegerBoundsForVariable
in interface Binding
public Sequence<?> evaluateVariable(XPathContext c)
evaluateVariable
in interface Binding
c
- the XPath dynamic evaluation contextpublic boolean isCompatible(LocalParam other)
other
- - the LocalParam object to comparepublic boolean isLiftable(boolean forStreaming)
isLiftable
in class Expression
forStreaming
- true if compiling streamable codepublic boolean hasVariableBinding(Binding binding)
hasVariableBinding
in class Expression
binding
- the variable bindingpublic ItemType getItemType()
getItemType
in class Instruction
public int computeCardinality()
computeCardinality
in class Instruction
public int computeSpecialProperties()
computeSpecialProperties
in class Instruction
public boolean mayCreateNewNodes()
mayCreateNewNodes
in class Instruction
public java.lang.String getExpressionName()
getExpressionName
in class Instruction
public java.lang.String toShortString()
toShortString
in class Expression
public void export(ExpressionPresenter out) throws XPathException
export
in interface ExportAgent
export
in class Expression
out
- the expression presenter used to display the structureXPathException
- if the export fails, for example if an expression is found that won't work
in the target environment.public void setIndexedVariable()
setIndexedVariable
in interface LocalBinding
public boolean isIndexedVariable()
isIndexedVariable
in interface LocalBinding
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.