net.sf.saxon.instruct

Class GlobalVariable

Implemented Interfaces:
Container, Serializable, SourceLocator, Binding, EvaluableItem, InstructionInfoProvider, SequenceIterable, SourceLocator, TailCallReturner
Known Direct Subclasses:
GlobalParam

public class GlobalVariable
extends GeneralVariable
implements Container

A compiled global variable in a stylesheet or query.

Field Summary

Fields inherited from class net.sf.saxon.instruct.GeneralVariable

evaluationMode, referenceCount, slotNumber, variableQName

Fields inherited from class net.sf.saxon.expr.Expression

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

GlobalVariable()
Create a global variable

Method Summary

ValueRepresentation
evaluateVariable(XPathContext context)
Evaluate the variable
Executable
getExecutable()
Get the executable containing this global variable
int
getHostLanguage()
Get the host language for this declaration
InstructionInfo
getInstructionInfo()
Get InstructionInfo for this expression
ValueRepresentation
getSelectValue(XPathContext context)
Evaluate the variable.
boolean
isGlobal()
Is this a global variable?
void
lookForCycles(Stack referees, XQueryFunctionLibrary globalFunctionLibrary)
Check for cycles in this variable definition
TailCall
processLeavingTail(XPathContext context)
Process the variable declaration
void
setContainsLocals(SlotManager map)
The expression that initializes a global variable may itself use local variables.
void
setExecutable(Executable executable)
Set the containing executable
void
setHostLanguage(int language)
Set the host language for this declaration

Methods inherited from class net.sf.saxon.instruct.GeneralVariable

copy, evaluateItem, explain, getCardinality, getEvaluationMode, getInstructionNameCode, getItemType, getLocalSlotNumber, getRequiredType, getSelectExpression, getSelectValue, getSlotNumber, getVariableQName, init, isAssignable, isGlobal, isImplicitlyRequiredParam, isRequiredParam, isTunnelParam, iterate, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, setAssignable, setImplicitlyRequiredParam, setReferenceCount, setRequiredParam, setRequiredType, setSelectExpression, setSlotNumber, setTunnel, setVariableQName, simplify, typeCheck

Methods inherited from class net.sf.saxon.instruct.Instruction

assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, createsNewNodes, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, isXSLT, iterate, process, processLeavingTail, promote, promoteInst, simplify

Methods inherited from class net.sf.saxon.expr.Expression

addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError

Constructor Details

GlobalVariable

public GlobalVariable()
Create a global variable

Method Details

evaluateVariable

public ValueRepresentation evaluateVariable(XPathContext context)
            throws XPathException
Evaluate the variable
Specified by:
evaluateVariable in interface Binding

getExecutable

public Executable getExecutable()
Get the executable containing this global variable
Specified by:
getExecutable in interface Container
Overrides:
getExecutable in interface Expression
Returns:
the containing executable

getHostLanguage

public int getHostLanguage()
Get the host language for this declaration
Specified by:
getHostLanguage in interface Container
Overrides:
getHostLanguage in interface Expression
Returns:
the host language (for example XSLT, XQuery)

getInstructionInfo

public InstructionInfo getInstructionInfo()
Get InstructionInfo for this expression
Specified by:
getInstructionInfo in interface InstructionInfoProvider
Overrides:
getInstructionInfo in interface Instruction

getSelectValue

public ValueRepresentation getSelectValue(XPathContext context)
            throws XPathException
Evaluate the variable. That is, get the value of the select expression if present or the content of the element otherwise, either as a tree or as a sequence
Overrides:
getSelectValue in interface GeneralVariable

isGlobal

public boolean isGlobal()
Is this a global variable?
Specified by:
isGlobal in interface Binding
Overrides:
isGlobal in interface GeneralVariable
Returns:
true (yes, it is a global variable)

lookForCycles

public void lookForCycles(Stack referees,
                          XQueryFunctionLibrary globalFunctionLibrary)
            throws XPathException
Check for cycles in this variable definition
Parameters:
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 functions

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
            throws XPathException
Process the variable declaration
Specified by:
processLeavingTail in interface TailCallReturner
Overrides:
processLeavingTail in interface Instruction

setContainsLocals

public void setContainsLocals(SlotManager map)
The expression that initializes a global variable may itself use local variables. In this case a stack frame needs to be allocated while evaluating the global variable
Parameters:
map - The stack frame map for local variables used while evaluating this global variable.

setExecutable

public void setExecutable(Executable executable)
Set the containing executable
Parameters:
executable - the executable that contains this global variable

setHostLanguage

public void setHostLanguage(int language)
Set the host language for this declaration
Parameters:
language - the host language (for example XSLT, XQuery)