public class GlobalVariable extends Actor implements Binding, Declaration, InstructionInfo, ContextOriginator
Modifier and Type | Field and Description |
---|---|
protected java.util.List<BindingReference> |
references |
Constructor and Description |
---|
GlobalVariable()
Create a global variable
|
Modifier and Type | Method and Description |
---|---|
protected Sequence |
actuallyEvaluate(XPathContext context,
Component target)
Evaluate the global variable, and save its value for use in subsequent references.
|
void |
addReference(VariableReference ref,
boolean isLoopingReference)
Register a variable reference that refers to the variable bound in this expression
|
void |
compile(Executable exec,
int slot)
Create a compiled representation of this global variable
|
Sequence |
evaluateVariable(XPathContext context)
Evaluate the variable
|
Sequence |
evaluateVariable(XPathContext context,
Component target)
Evaluate the variable
|
void |
export(ExpressionPresenter presenter)
Diagnostic print of expression structure.
|
int |
getBinderySlotNumber()
Get the slot number allocated to this variable in the Bindery
|
int |
getComponentKind()
Get the kind of component that this represents, using integer constants such as
StandardNames.XSL_FUNCTION |
int |
getConstructType()
Get the type of construct.
|
protected java.lang.String |
getFlags() |
int |
getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
|
IntegerValue[] |
getIntegerBoundsForVariable()
If the variable is bound to an integer, get the minimum and maximum possible values.
|
int |
getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number.
|
StructuredQName |
getObjectName()
Get a name identifying the object of the expression, for example a function name, template name,
variable name, key name, element name, etc.
|
GlobalVariable |
getOriginalVariable()
Get the original declaration of this variable
|
java.util.Iterator<java.lang.String> |
getProperties()
Get an iterator over all the properties available.
|
java.lang.Object |
getProperty(java.lang.String name)
Get the value of a particular property of the instruction.
|
SequenceType |
getRequiredType()
Get the required type of this variable
|
Expression |
getSelectExpression()
Get the expression to which this variable is bound
|
Sequence |
getSelectValue(XPathContext context,
Component target)
Evaluate the variable.
|
SymbolicName |
getSymbolicName()
Get the symbolic name of the component
|
GlobalVariable |
getUltimateOriginalVariable()
Get the original declaration of this variable, or its original declaration, transitively
|
StructuredQName |
getVariableQName()
Get the name of the variable
|
void |
init(Expression select,
StructuredQName qName)
Initialize the properties of the variable
|
boolean |
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign
extension element.
|
boolean |
isGlobal()
Is this a global variable?
|
boolean |
isIndexedVariable()
Ask whether this is an indexed variable
|
boolean |
isPrivate()
Ask whether this global variable is private
|
boolean |
isRequiredParam()
Ask whether this variable represents a required parameter
|
boolean |
isUnused()
Ask whether this variable is unused.
|
java.util.Iterator |
iterateReferences()
Iterate over the references to this variable
|
void |
lookForCycles(java.util.Stack<java.lang.Object> referees,
XQueryFunctionLibrary globalFunctionLibrary)
Check for cycles in this variable definition
|
void |
registerReference(BindingReference ref)
Register a variable reference that refers to this global variable
|
void |
setAssignable(boolean assignable)
Indicate whether this variable is assignable using saxon:assign
|
void |
setBinderySlotNumber(int s)
Set the slot number of this variable in the Bindery
|
void |
setContainsLocals(SlotManager map)
The expression that initializes a global variable may itself use local variables.
|
protected static void |
setDependencies(GlobalVariable var,
XPathContext context)
Get the variable that is immediately dependent on this one, and register the dependency, so
that circularities can be detected across threads.
|
void |
setIndexedVariable()
Mark this as an indexed variable, to allow fast searching
|
void |
setOriginalVariable(GlobalVariable var)
Say that this (XQuery) variable is a copy of some originally declared variable.
|
void |
setPrivate(boolean b)
Say whether this global variable is private
|
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 |
setUnused(boolean unused)
Say whether this variable is unused.
|
void |
setVariableQName(StructuredQName s)
Set the name of the variable
|
void |
typeCheck(ExpressionVisitor visitor)
Type check the compiled representation of this global variable
|
allocateAllBindingSlots, allocateBindingSlotsRecursive, getBody, getColumnNumber, getDeclaredVisibility, getDeclaringComponent, getLineNumber, getLocation, getPackageData, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, isExportable, makeDeclaringComponent, saveLocation, setBody, setChildExpression, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getColumnNumber, getLineNumber, getPublicId, getSystemId, saveLocation
protected java.util.List<BindingReference> references
public void init(Expression select, StructuredQName qName)
select
- the expression to which the variable is boundqName
- the name of the variablepublic SymbolicName getSymbolicName()
getSymbolicName
in class Actor
public void setSelectExpression(Expression select)
select
- the initializing expression. May be null in the case of a global parameter with no initializer.public Expression getSelectExpression()
public void setRequiredType(SequenceType required)
required
- the required typepublic SequenceType getRequiredType()
getRequiredType
in interface Binding
public void setOriginalVariable(GlobalVariable var)
var
- the variable in the imported module from which this variable is derivedpublic GlobalVariable getOriginalVariable()
public GlobalVariable getUltimateOriginalVariable()
public void setUnused(boolean unused)
unused
- set to true if this global variable is to be marked as unused.public boolean isUnused()
public boolean isPrivate()
public void setPrivate(boolean b)
b
- true if this variable is externalpublic void setAssignable(boolean assignable)
assignable
- true if this variable is assignablepublic final boolean isAssignable()
isAssignable
in interface Binding
public int getConstructType()
StandardNames
: all less than 1024)
or it will be a constant in class LocationKind
.getConstructType
in interface InstructionInfo
public StructuredQName getObjectName()
getObjectName
in interface InstructionInfo
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface InstructionInfo
getProperty
in class Actor
name
- The name of the required propertypublic java.util.Iterator<java.lang.String> getProperties()
getProperties
in interface InstructionInfo
getProperties
in class Actor
public int getHostLanguage()
Configuration.XSLT
or Configuration.XQUERY
public void setIndexedVariable()
public boolean isIndexedVariable()
public void setContainsLocals(SlotManager map)
map
- The stack frame map for local variables used while evaluating this global
variable.public boolean isGlobal()
public void registerReference(BindingReference ref)
ref
- the variable referencepublic java.util.Iterator iterateReferences()
VariableReference
public int getBinderySlotNumber()
public void setBinderySlotNumber(int s)
s
- the slot number, that is, the position allocated to this variable within the Binderypublic void setRequiredParam(boolean requiredParam)
requiredParam
- true if this is a required parameterpublic boolean isRequiredParam()
public void compile(Executable exec, int slot) throws XPathException
exec
- the executableslot
- the slot number allocated to this variableXPathException
- if compile-time errors are found.public void typeCheck(ExpressionVisitor visitor) throws XPathException
visitor
- an expression visitorXPathException
- if compile-time errors are found.public void lookForCycles(java.util.Stack<java.lang.Object> referees, XQueryFunctionLibrary globalFunctionLibrary) throws XPathException
referees
- the calls leading up to this one; it's an error if this variable is on the
stack, because that means it calls itself directly or indirectly. The stack may contain
variable definitions (GlobalVariable objects) and user-defined functions (UserFunction objects).
It will never contain the same object more than once.globalFunctionLibrary
- the library containing all global functionsXPathException
- if cycles are foundpublic Sequence getSelectValue(XPathContext context, Component target) throws XPathException
context
- the dynamic evaluation contexttarget
- the component representing the variable to be evaluatedXPathException
- if a dynamic error occurs during evaluationpublic Sequence evaluateVariable(XPathContext context) throws XPathException
evaluateVariable
in interface Binding
context
- the XPath dynamic evaluation contextXPathException
- if an error occurs while evaluating
the variablepublic Sequence evaluateVariable(XPathContext context, Component target) throws XPathException
XPathException
protected Sequence actuallyEvaluate(XPathContext context, Component target) throws XPathException
context
- the XPath dynamic contexttarget
- the component representing this variable (in the context of a package where it is used)XPathException
- if evaluation failsprotected static void setDependencies(GlobalVariable var, XPathContext context) throws XPathException
var
- the global variable or parameter being evaluatedcontext
- the dynamic evaluation contextXPathException
public IntegerValue[] getIntegerBoundsForVariable()
getIntegerBoundsForVariable
in interface Binding
public int getLocalSlotNumber()
public void setVariableQName(StructuredQName s)
s
- the name of the variable (a QName)public StructuredQName getVariableQName()
getVariableQName
in interface Binding
public void addReference(VariableReference ref, boolean isLoopingReference)
addReference
in interface Binding
ref
- isLoopingReference
- - true if the reference occurs within a loop, such as the predicate
of a filter expressionpublic int getComponentKind()
StandardNames.XSL_FUNCTION
getComponentKind
in class Actor
public void export(ExpressionPresenter presenter) throws XPathException
export
in class Actor
presenter
- the expression presenter used to display the structureXPathException
protected java.lang.String getFlags()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.