public class GlobalVariable extends ComponentBody implements Binding, Container, Declaration, InstructionInfo
Modifier and Type | Field and Description |
---|---|
protected List<BindingReference> |
references |
body
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(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
|
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 |
Configuration |
getConfiguration()
Get the Configuration to which this Container belongs
|
int |
getConstructType()
Get the type of construct.
|
int |
getContainerGranularity()
Get the granularity of the container.
|
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
|
Iterator<String> |
getProperties()
Get an iterator over all the properties available.
|
Object |
getProperty(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.
|
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
|
Iterator |
iterateReferences()
Iterate over the references to this variable
|
void |
lookForCycles(Stack<Container> 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(Bindery bindery,
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 a "parameter" (an external variable, in XQuery terminology)
|
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 |
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, getDeclaringComponent, getLineNumber, getLocationProvider, getPackageData, getPublicId, getStackFrameMap, getSystemId, makeDeclaringComponent, setBody, setHostLanguage, setLineNumber, setPackageData, setStackFrameMap, setSystemId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPackageData
getLineNumber, getSystemId
getColumnNumber, getPublicId
protected List<BindingReference> references
public void init(Expression select, StructuredQName qName)
select
- the expression to which the variable is boundqName
- the name of the variablepublic 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 Configuration getConfiguration()
getConfiguration
in interface Container
getConfiguration
in class ComponentBody
public void setOriginalVariable(GlobalVariable var)
var
- the variable in the imported module from which this variable is derivedpublic GlobalVariable getOriginalVariable()
public GlobalVariable getUltimateOriginalVariable()
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 Location
.getConstructType
in interface InstructionInfo
public StructuredQName getObjectName()
getObjectName
in interface InstructionInfo
public Object getProperty(String name)
getProperty
in interface InstructionInfo
getProperty
in class ComponentBody
name
- The name of the required propertypublic Iterator<String> getProperties()
getProperties
in interface InstructionInfo
getProperties
in class ComponentBody
public int getHostLanguage()
getHostLanguage
in interface Container
getHostLanguage
in class ComponentBody
Configuration.XSLT
or Configuration.XQUERY
public void setIndexedVariable()
public boolean isIndexedVariable()
public int getContainerGranularity()
getContainerGranularity
in interface Container
getContainerGranularity
in class ComponentBody
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 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(Stack<Container> 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(Bindery bindery, GlobalVariable var, XPathContext context) throws XPathException
bindery
- the Binderyvar
- 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(boolean isLoopingReference)
addReference
in interface Binding
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 ComponentBody
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.