Package com.saxonica.ee.bytecode

## Class CompiledExpression

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - com.saxonica.ee.bytecode.CompiledExpression

- All Implemented Interfaces:
    `ExportAgent`, `Locatable`, `IdentityComparable`, `Traceable`

      public class CompiledExpression
      extends Expression

  An expression that has been compiled to Java bytecode. The actual bytecode is contained in a separate object of type `GeneratedCode`, to which evaluation is delegated

- - ### Field Summary

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

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CompiledExpression​(Expression original, GeneratedCode byteCode)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `PathMap.PathMapNodeSet` | `addToPathMap​(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)` | Add a representation of this expression to a PathMap.
    `void` | `checkForUpdatingSubexpressions()` | Check to ensure that this expression does not contain any inappropriate updating subexpressions.
    `void` | `checkPermittedContents​(SchemaType parentType, boolean whole)` | Check that any elements and attributes constructed or returned by this expression are acceptable in the content model of a given complex type.
    `protected int` | `computeCardinality()` | Compute the static cardinality of this expression
    `int` | `computeDependencies()` | Compute the dependencies of an expression, as the union of the dependencies of its subexpressions.
    `int` | `computeHashCode()` | Hashcode supporting equals()
    `protected int` | `computeSpecialProperties()` | Compute the special properties of this expression.
    `Expression` | `copy​(RebindingMap rebindings)` | Copy an expression.
    `boolean` | `effectiveBooleanValue​(XPathContext context)` | Get the effective boolean value of the expression.
    `boolean` | `equals​(java.lang.Object other)` | Is this expression the same as another expression?
    `Item` | `evaluateItem​(XPathContext context)` | Evaluate an expression as a single item.
    `void` | `evaluatePendingUpdates​(XPathContext context, PendingUpdateList pul)` | Evaluate an updating expression, adding the results to a Pending Update List.
    `void` | `export​(ExpressionPresenter out)` | Diagnostic print of expression structure.
    `int` | `getCardinality()` | Determine the static cardinality of the expression.
    `java.lang.String` | `getClassName()` |
    `int` | `getDependencies()` | Determine which aspects of the context the expression depends on.
    `java.lang.String` | `getExpressionName()` | Get a name identifying the kind of expression, in terms meaningful to a user.
    `GeneratedCode` | `getGeneratedCode()` |
    `int` | `getImplementationMethod()` | An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
    `Expression` | `getInterpretedExpression()` | Get the original (uncompiled) expression of which this is the compiled form
    `int` | `getIntrinsicDependencies()` | Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
    `ItemType` | `getItemType()` | Determine the static item type of the expression, as precisely possible.
    `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.
    `java.util.Iterator<java.lang.String>` | `getProperties()` | Get an iterator over all the properties available.
    `java.lang.Object` | `getProperty​(java.lang.String name)` |
    `boolean` | `isSubtreeExpression()` | Determine whether the expression can be evaluated without reference to the part of the context document outside the subtree rooted at the context node.
    `boolean` | `isUpdatingExpression()` | Determine whether this is an updating expression as defined in the XQuery update specification
    `boolean` | `isVacuousExpression()` | Determine whether this is a vacuous expression as defined in the XQuery update specification
    `SequenceIterator` | `iterate​(XPathContext context)` | Return an Iterator to iterate over the values of a sequence.
    `void` | `process​(Outputter output, XPathContext context)` | Process the instruction, without returning any tail calls
    `void` | `setClassName​(java.lang.String cname)` |
    `java.lang.String` | `toString()` | The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

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

      `adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, computeStaticProperties, dynamicError, evaluateAsString, explain, getConfiguration, getCost, getEvaluationMethod, getExtraProperty, getIntegerBounds, getLocalRetainedStaticContext, getLocation, getNetCost, getPackageData, getParentExpression, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, markTailFunctionCalls, operandList, operands, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toShortString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.trace.Traceable

      `gatherProperties`

- - ### Constructor Detail

    - #### CompiledExpression

          public CompiledExpression​(Expression original,
                                    GeneratedCode byteCode)

  - ### Method Detail

    - #### getInterpretedExpression

          public Expression getInterpretedExpression()

      Get the original (uncompiled) expression of which this is the compiled form
      Overrides:
        `getInterpretedExpression` in class `Expression`
      Returns:
        the original expression

    - #### getGeneratedCode

          public GeneratedCode getGeneratedCode()

    - #### setClassName

          public void setClassName​(java.lang.String cname)

    - #### getClassName

          public java.lang.String getClassName()

    - #### getExpressionName

          public java.lang.String getExpressionName()

      Description copied from class: `Expression`
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
        `getExpressionName` in class `Expression`
      Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.

    - #### getImplementationMethod

          public int getImplementationMethod()

      Description copied from class: `Expression`
      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Specified by:
        `getImplementationMethod` in class `Expression`
      Returns:
        the implementation method, for example `Expression.ITERATE_METHOD` or `Expression.EVALUATE_METHOD` or `Expression.PROCESS_METHOD`

    - #### getCardinality

          public int getCardinality()

      Description copied from class: `Expression`
      Determine the static cardinality of the expression. This establishes how many items there will be in the result of the expression, at compile time (i.e., without actually evaluating the result.
      Overrides:
        `getCardinality` in class `Expression`
      Returns:
        one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).

    - #### getItemType

          public ItemType getItemType()

      Description copied from class: `Expression`
      Determine the static item type of the expression, as precisely possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

      This method should always return a result, though it may be the best approximation that is available at the time.

      Specified by:
        `getItemType` in class `Expression`
      Returns:
        a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

    - #### getDependencies

          public int getDependencies()

      Description copied from class: `Expression`
      Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as XPathContext.VARIABLES and XPathContext.CURRENT_NODE. The default implementation combines the intrinsic dependencies of this expression with the dependencies of the subexpressions, computed recursively. This is overridden for expressions such as FilterExpression where a subexpression's dependencies are not necessarily inherited by the parent expression.
      Overrides:
        `getDependencies` in class `Expression`
      Returns:
        a set of bit-significant flags identifying the dependencies of the expression

    - #### process

          public void process​(Outputter output,
                              XPathContext context)
                       throws XPathException

      Description copied from class: `Expression`
      Process the instruction, without returning any tail calls
      Overrides:
        `process` in class `Expression`
      Parameters:
        `output` - the destination for the result
        `context` - The dynamic context, giving access to the current node, the current variables, etc.
      Throws:
        `XPathException` - if a dynamic error occurs

    - #### evaluatePendingUpdates

          public void evaluatePendingUpdates​(XPathContext context,
                                             PendingUpdateList pul)
                                      throws XPathException

      Description copied from class: `Expression`
      Evaluate an updating expression, adding the results to a Pending Update List. The default implementation of this method, which is used for non-updating expressions, throws an UnsupportedOperationException
      Overrides:
        `evaluatePendingUpdates` in class `Expression`
      Parameters:
        `context` - the XPath dynamic evaluation context
        `pul` - the pending update list to which the results should be written
      Throws:
        `XPathException` - if evaluation fails

    - #### toString

          public java.lang.String toString()

      Description copied from class: `Expression`

      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

      For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.

      In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.

      Overrides:
        `toString` in class `Expression`
      Returns:
        a representation of the expression as a string

    - #### export

          public void export​(ExpressionPresenter out)
                      throws XPathException

      Description copied from class: `Expression`
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
        `export` in interface `ExportAgent`
      Specified by:
        `export` in class `Expression`
      Parameters:
        `out` - the expression presenter used to display the structure
      Throws:
        `XPathException` - if the export fails, for example if an expression is found that won't work in the target environment.

    - #### checkPermittedContents

          public void checkPermittedContents​(SchemaType parentType,
                                             boolean whole)
                                      throws XPathException

      Description copied from class: `Expression`
      Check that any elements and attributes constructed or returned by this expression are acceptable in the content model of a given complex type. It's always OK to say yes, since the check will be repeated at run-time. The process of checking element and attribute constructors against the content model of a complex type also registers the type of content expected of those constructors, so the static validation can continue recursively.
      Overrides:
        `checkPermittedContents` in class `Expression`
      Parameters:
        `parentType` - the "given complex type": the method is checking that the nodes returned by this expression are acceptable members of the content model of this type
        `whole` - if true, we want to check that the value of this expression satisfies the content model as a whole; if false we want to check that the value of the expression is acceptable as one part of the content
      Throws:
        `XPathException` - if the value delivered by this expression cannot be part of the content model of the given type

    - #### computeCardinality

          protected int computeCardinality()

      Description copied from class: `Expression`
      Compute the static cardinality of this expression
      Specified by:
        `computeCardinality` in class `Expression`
      Returns:
        the computed cardinality, as one of the values `StaticProperty.ALLOWS_ZERO_OR_ONE`, `StaticProperty.EXACTLY_ONE`, `StaticProperty.ALLOWS_ONE_OR_MORE`, `StaticProperty.ALLOWS_ZERO_OR_MORE`. May also return `StaticProperty.ALLOWS_ZERO` if the result is known to be an empty sequence, or `StaticProperty.ALLOWS_MANY` if if is known to return a sequence of length two or more.

    - #### computeSpecialProperties

          protected int computeSpecialProperties()

      Description copied from class: `Expression`
      Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in class `StaticProperty`. The "special" properties are properties other than cardinality and dependencies, and most of them relate to properties of node sequences, for example whether the nodes are in document order.
      Overrides:
        `computeSpecialProperties` in class `Expression`
      Returns:
        the special properties, as a bit-significant integer

    - #### computeDependencies

          public int computeDependencies()

      Description copied from class: `Expression`
      Compute the dependencies of an expression, as the union of the dependencies of its subexpressions. (This is overridden for path expressions and filter expressions, where the dependencies of a subexpression are not all propogated). This method should be called only once, to compute the dependencies; after that, getDependencies should be used.
      Overrides:
        `computeDependencies` in class `Expression`
      Returns:
        the depencies, as a bit-mask

    - #### getIntrinsicDependencies

          public int getIntrinsicDependencies()

      Description copied from class: `Expression`
      Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
      Overrides:
        `getIntrinsicDependencies` in class `Expression`
      Returns:
        a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty

    - #### checkForUpdatingSubexpressions

          public void checkForUpdatingSubexpressions()
                                              throws XPathException

      Description copied from class: `Expression`
      Check to ensure that this expression does not contain any inappropriate updating subexpressions. This check is overridden for those expressions that permit updating subexpressions.
      Overrides:
        `checkForUpdatingSubexpressions` in class `Expression`
      Throws:
        `XPathException` - if the expression has a non-permitted updating subexpression

    - #### isUpdatingExpression

          public boolean isUpdatingExpression()

      Description copied from class: `Expression`
      Determine whether this is an updating expression as defined in the XQuery update specification
      Overrides:
        `isUpdatingExpression` in class `Expression`
      Returns:
        true if this is an updating expression

    - #### isVacuousExpression

          public boolean isVacuousExpression()

      Description copied from class: `Expression`
      Determine whether this is a vacuous expression as defined in the XQuery update specification
      Overrides:
        `isVacuousExpression` in class `Expression`
      Returns:
        true if this expression is vacuous

    - #### copy

          public Expression copy​(RebindingMap rebindings)

      Description copied from class: `Expression`
      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      Parameters:
        `rebindings` - a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.
      Returns:
        the copy of the original expression

    - #### getObjectName

          public StructuredQName getObjectName()

      Description copied from interface: `Traceable`
      Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.
      Specified by:
        `getObjectName` in interface `Traceable`
      Overrides:
        `getObjectName` in class `Expression`
      Returns:
        the QName of the object declared or manipulated by this instruction or expression

    - #### equals

          public boolean equals​(java.lang.Object other)

      Is this expression the same as another expression?
      Overrides:
        `equals` in class `Expression`
      Parameters:
        `other` - the expression to be compared with this one
      Returns:
        true if the two expressions are statically equivalent

    - #### computeHashCode

          public int computeHashCode()

      Hashcode supporting equals()
      Overrides:
        `computeHashCode` in class `Expression`
      Returns:
        a computed hash code

    - #### getProperty

          public java.lang.Object getProperty​(java.lang.String name)

      Overrides:
        `getProperty` in class `Expression`

    - #### getProperties

          public java.util.Iterator<java.lang.String> getProperties()

      Description copied from class: `Expression`
      Get an iterator over all the properties available. The values returned by the iterator will be of type String, and each string can be supplied as input to the getProperty() method to retrieve the value of the property. The iterator may return properties whose value is null.
      Overrides:
        `getProperties` in class `Expression`
      Returns:
        an iterator over the properties

    - #### addToPathMap

          public PathMap.PathMapNodeSet addToPathMap​(PathMap pathMap,
                                                     PathMap.PathMapNodeSet pathMapNodeSet)

      Description copied from class: `Expression`
      Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.

      The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.

      Overrides:
        `addToPathMap` in class `Expression`
      Parameters:
        `pathMap` - the PathMap to which the expression should be added
        `pathMapNodeSet` - the PathMapNodeSet to which the paths embodied in this expression should be added
      Returns:
        the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.

    - #### isSubtreeExpression

          public boolean isSubtreeExpression()

      Description copied from class: `Expression`
      Determine whether the expression can be evaluated without reference to the part of the context document outside the subtree rooted at the context node.
      Overrides:
        `isSubtreeExpression` in class `Expression`
      Returns:
        true if the expression has no dependencies on the context node, or if the only dependencies on the context node are downward selections using the self, child, descendant, attribute, and namespace axes.

    - #### iterate

          public SequenceIterator iterate​(XPathContext context)
                                   throws XPathException

      Description copied from class: `Expression`
      Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.
      Overrides:
        `iterate` in class `Expression`
      Parameters:
        `context` - supplies the context for evaluation
      Returns:
        a SequenceIterator that can be used to iterate over the result of the expression
      Throws:
        `XPathException` - if any dynamic error occurs evaluating the expression

    - #### evaluateItem

          public Item evaluateItem​(XPathContext context)
                            throws XPathException

      Description copied from class: `Expression`
      Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.
      Overrides:
        `evaluateItem` in class `Expression`
      Parameters:
        `context` - The context in which the expression is to be evaluated
      Returns:
        the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
        `XPathException` - if any dynamic error occurs evaluating the expression

    - #### effectiveBooleanValue

          public boolean effectiveBooleanValue​(XPathContext context)
                                        throws XPathException

      Description copied from class: `Expression`
      Get the effective boolean value of the expression. This returns false if the value is the empty sequence, a zero-length string, a number equal to zero, or the boolean false. Otherwise it returns true.
      Overrides:
        `effectiveBooleanValue` in class `Expression`
      Parameters:
        `context` - The context in which the expression is to be evaluated
      Returns:
        the effective boolean value
      Throws:
        `XPathException` - if any dynamic error occurs evaluating the expression