public class GlobalVariable extends GeneralVariable implements Container, Declaration, InstructionInfo
Modifier and Type | Field and Description |
---|---|
protected List<BindingReference> |
references |
evaluationMode, referenceCount, slotNumber, variableQName
Constructor and Description |
---|
GlobalVariable()
Create a global variable
|
Modifier and Type | Method and Description |
---|---|
protected Sequence |
actuallyEvaluate(XPathContext context)
Evaluate the global variable, and save its value for use in subsequent references.
|
void |
compile(Executable exec,
int slot)
Create a compiled representation of this global variable
|
Sequence |
evaluateVariable(XPathContext context)
Evaluate the variable
|
int |
getColumnNumber(long locationId)
Get the column number within the document, entity, or module containing a particular location
|
int |
getConstructType()
Get the type of construct.
|
Container |
getContainer()
Get the container in which this expression is located.
|
int |
getContainerGranularity()
Get the granularity of the container.
|
Executable |
getExecutable()
Get the executable containing this global variable
|
int |
getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container
|
int |
getLineNumber()
Get the line number where the declaration appears
|
int |
getLineNumber(long locationId)
Get the line number within the document, entity or module containing a particular location
|
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.
|
Sequence |
getSelectValue(XPathContext context)
Evaluate the variable.
|
String |
getSystemId()
Get the system ID of the module containing the variable declaration
|
GlobalVariable |
getUltimateOriginalVariable()
Get the original declaration of this variable, or its original declaration, transitively
|
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
|
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 |
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 |
setExecutable(Executable executable)
Set the containing executable
|
void |
setIndexedVariable()
Mark this as an indexed variable, to allow fast searching
|
void |
setLineNumber(int lineNumber)
Set the line number where the variable declaration appears in the source
|
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 |
setSystemId(String systemId)
Set the system ID of the module where the variable declaration appears
|
void |
typeCheck(ExpressionVisitor visitor)
Type check the compiled representation of this global variable
|
addReference, checkAgainstRequiredType, computeEvaluationMode, copy, explain, getCardinality, getColumnNumber, getEvaluationMode, getInstructionNameCode, getIntegerBoundsForVariable, getLocalSlotNumber, getLocationId, getLocationProvider, getPublicId, getRequiredType, getSelectExpression, getSlotNumber, getSystemId, getVariableQName, init, isImplicitlyRequiredParam, isRequiredParam, isTunnelParam, iterateSubExpressions, optimize, replaceSubExpression, setContainer, setImplicitlyRequiredParam, setLocationId, setReferenceCount, setRequiredParam, setRequiredType, setSelectExpression, setSlotNumber, setTunnel, setVariableQName, simplify, typeCheck
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLocationProvider
getColumnNumber, getPublicId
getColumnNumber, getPublicId
getSystemId
protected List<BindingReference> references
public Executable getExecutable()
getExecutable
in interface Container
getExecutable
in class GeneralVariable
public void setExecutable(Executable executable)
executable
- the executable that contains this global variablepublic void setOriginalVariable(GlobalVariable var)
var
- the variable in the imported module from which this variable is derivedpublic GlobalVariable getOriginalVariable()
public GlobalVariable getUltimateOriginalVariable()
public void setLineNumber(int lineNumber)
lineNumber
- the line numberpublic int getLineNumber()
getLineNumber
in interface SourceLocator
getLineNumber
in interface InstructionInfo
getLineNumber
in interface Locator
getLineNumber
in class GeneralVariable
public int getLineNumber(long locationId)
LocationProvider
getLineNumber
in interface LocationProvider
locationId
- identifier of the location in question (as passed down the Receiver pipeline)public void setSystemId(String systemId)
systemId
- the System ID (base URI)public String getSystemId()
getSystemId
in interface SourceLocator
getSystemId
in interface InstructionInfo
getSystemId
in interface Locator
getSystemId
in class GeneralVariable
public int getColumnNumber(long locationId)
getColumnNumber
in interface LocationProvider
locationId
- identifier of the location in question (as passed down the Receiver pipeline)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
isAssignable
in class GeneralVariable
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
name
- The name of the required propertypublic Iterator<String> getProperties()
getProperties
in interface InstructionInfo
public Container getContainer()
getContainer
in class GeneralVariable
public int getHostLanguage()
getHostLanguage
in interface Container
Configuration.XSLT
or Configuration.XQUERY
public void setIndexedVariable()
public boolean isIndexedVariable()
public int getContainerGranularity()
getContainerGranularity
in interface Container
public void setContainsLocals(SlotManager map)
map
- The stack frame map for local variables used while evaluating this global
variable.public boolean isGlobal()
isGlobal
in interface Binding
isGlobal
in class GeneralVariable
public void registerReference(BindingReference ref)
ref
- the variable referencepublic Iterator iterateReferences()
VariableReference
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) throws XPathException
getSelectValue
in class GeneralVariable
context
- the XPath dynamic contextXPathException
- if evaluation of the select expression fails
with a dynamic errorpublic Sequence evaluateVariable(XPathContext context) throws XPathException
evaluateVariable
in interface Binding
context
- the XPath dynamic evaluation contextXPathException
- if an error occurs while evaluating
the variableprotected Sequence actuallyEvaluate(XPathContext context) throws XPathException
context
- the XPath dynamic contextXPathException
- 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
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.