## net.sf.saxon.instruct
Class InstructionWithChildren

    java.lang.Object
      |
      +--net.sf.saxon.expr.ComputedExpression
            |
            +--net.sf.saxon.instruct.Instruction
                  |
                  +--net.sf.saxon.instruct.InstructionWithChildren

All Implemented Interfaces:
  Container, Expression, InstructionInfoProvider, java.io.Serializable, javax.xml.transform.SourceLocator

Direct Known Subclasses:
  Block, Doctype, DocumentInstr, ElementCreator, Message, ResultDocument, SimpleNodeConstructor

public abstract class InstructionWithChildren
extends Instruction

Abstract superclass for all instructions in the compiled stylesheet that have child instructions. This does not include instructions such as xsl:perform-sort that have child instructions, but whose child instructions are compiled directly into an expression (or a Block).

See Also:
  Serialized Form

Field Summary
`protected Expression[]` `children`

Fields inherited from class net.sf.saxon.expr.ComputedExpression
`locationId, staticProperties`

Fields inherited from interface net.sf.saxon.expr.Expression
`EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD`

Constructor Summary
`InstructionWithChildren()` Constructor

Method Summary
`Expression` `analyze(StaticContext env, ItemType contextItemType)` Perform static analysis of an expression and its subexpressions.
`static void` `displayChildren(Expression[] children, int level, NamePool pool, java.io.PrintStream out)` Display the children of an instruction for diagostics
`Expression[]` `getChildren()` Get the children of this instruction
`java.util.Iterator` `iterateSubExpressions()` Get the immediate sub-expressions of this expression.
`protected void` `processChildren(XPathContext context)` Process the children of this instruction, including any tail calls
`protected TailCall` `processChildrenLeavingTail(XPathContext context)` Process the children of this instruction, returning any tail call made by the last child instruction
`protected void` `promoteInst(PromotionOffer offer)` Handle promotion offers, that is, non-local tree rewrites.
`void` `setChildren(Expression[] children)` Set the children of this instruction
`Expression` `simplify(StaticContext env)` Simplify an expression.

Methods inherited from class net.sf.saxon.instruct.Instruction
`appendItem, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getInstructionNameCode, getItemType, getSourceLocator, iterate, process, processLeavingTail, promote`

Methods inherited from class net.sf.saxon.expr.ComputedExpression
`adoptChildExpression, computeDependencies, computeStaticProperties, dynamicError, dynamicError, getCardinality, getColumnNumber, getConstructType, getDependencies, getExecutable, getIntrinsicDependencies, getLineNumber, getLocationId, getParentExpression, getPublicId, getSpecialProperties, getSystemId, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, typeError`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.xml.transform.SourceLocator
`getColumnNumber, getLineNumber, getPublicId, getSystemId`

Methods inherited from interface net.sf.saxon.expr.Expression
`display`

Field Detail

### children

    protected Expression[] children

Constructor Detail

### InstructionWithChildren

    public InstructionWithChildren()

  Constructor

Method Detail

### setChildren

    public void setChildren(Expression[] children)

  Set the children of this instruction

  Parameters:
    `children` - The instructions that are children of this instruction

### getChildren

    public Expression[] getChildren()

  Get the children of this instruction

  Returns:
    the children of this instruction, as an array of Instruction objects. May return either a zero-length array or null if there are no children

### displayChildren

    public static void displayChildren(Expression[] children,
                                       int level,
                                       NamePool pool,
                                       java.io.PrintStream out)

  Display the children of an instruction for diagostics

### simplify

    public Expression simplify(StaticContext env)
                        throws XPathException

  Simplify an expression. This performs any static optimization (by rewriting the expression as a different expression).

  Specified by:
    `simplify` in interface `Expression`
  Specified by:
    `simplify` in class `Instruction`
  Returns:
    the simplified expression
  Throws:
    `XPathException` - if an error is discovered during expression rewriting

### analyze

    public Expression analyze(StaticContext env,
                              ItemType contextItemType)
                       throws XPathException

  Perform static analysis of an expression and its subexpressions.

  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 will only be accurately known if they have been explicitly declared.

  Specified by:
    `analyze` in interface `Expression`
  Specified by:
    `analyze` in class `Instruction`
  Parameters:
    `env` - the static context of the expression
  Returns:
    the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
  Throws:
    `XPathException` - if an error is discovered during this phase (typically a type error)

### promoteInst

    protected void promoteInst(PromotionOffer offer)
                        throws XPathException

  Handle promotion offers, that is, non-local tree rewrites.

  Overrides:
    `promoteInst` in class `Instruction`
  Parameters:
    `offer` - The type of rewrite being offered
  Throws:
    `XPathException`

### iterateSubExpressions

    public java.util.Iterator iterateSubExpressions()

  Get the immediate sub-expressions of this expression.

  Specified by:
    `iterateSubExpressions` in interface `Expression`
  Overrides:
    `iterateSubExpressions` in class `ComputedExpression`
  Returns:
    an iterator containing the sub-expressions of this expression

### processChildren

    protected void processChildren(XPathContext context)
                            throws XPathException

  Process the children of this instruction, including any tail calls

  Parameters:
    `context` - The dynamic context for the transformation
  Throws:
    `XPathException` - if a dynamic error occurs

### processChildrenLeavingTail

    protected TailCall processChildrenLeavingTail(XPathContext context)
                                           throws XPathException

  Process the children of this instruction, returning any tail call made by the last child instruction

  Parameters:
    `context` - The dynamic context of the transformation, giving access to the current node, the current variables, etc.
  Returns:
    null if the instruction has completed execution; or a TailCall indicating a function call or template call that is delegated to the caller, to be made after the stack has been unwound so as to save stack space.
    `XPathException`